You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
spring-cloud-tencent/spring-cloud-tencent-examples/metadata-transfer-example
qingliu f5ec25ee57
feat: support actuator for sct core components
3 years ago
..
metadata-callee-service feat:merge features from 1.5.x-Hoxton.SR9. (#250) 3 years ago
metadata-caller-service feat: support actuator for sct core components 3 years ago
README-zh.md Add metedata transfer example for (2021.0). (#211) 3 years ago
README.md Add metedata transfer example for (2021.0). (#211) 3 years ago
pom.xml Add metedata transfer example for (2021.0). (#211) 3 years ago

README.md

Spring Cloud Tencent Metadata Transfer example

Example Introduction

This example shows how to use spring-cloud-starter-tencent-metadata-transfer in Spring Cloud project for its features.

This example contains metadata-callee-servicemetadata-caller-service.

Instruction

Configuration

The configuration is as the following shows. {ip} and {port} are Polaris backend IP address and port number.

spring:
  application:
    name: ${application.name}
  cloud:
    polaris:
      address: ${ip}:${port}

Maven Dependency

<dependency>
    <groupId>com.tencent.cloud</groupId>
    <artifactId>spring-cloud-starter-tencent-metadata-transfer</artifactId>
</dependency>

Launching Example

Launching Polaris Backend Service

Reference to Polaris Getting Started

Launching Application

  • IDEA Launching

  • spring-cloud-tencent-examples/metadata-transfer-example/metadata-callee-servicesMetadataCalleeService

  • spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service'sMetadataCallerService

  • Maven Package Launching

Execute under spring-cloud-tencent-examples/metadata-transfer-example

mvn clean package

Then find the jars under metadata-callee-servicemetadata-caller-service, and run it:

java -jar ${app.jar}

Launch application, change ${app.jar} to jar's package name.

Metadata Configuration

In the bootstrap.yml configuration file of the spring-cloud-tencent-examples/metadata-transfer-example/metadata-caller-service project

spring:
  cloud:
    tencent:
      metadata:
        # Defined your metadata keys & values
        content:
          # Example: intransitive
          CUSTOM-METADATA-KEY-LOCAL: CUSTOM-VALUE-LOCAL
          # Example: transitive
          CUSTOM-METADATA-KEY-TRANSITIVE: CUSTOM-VALUE-TRANSITIVE
        # Assigned which metadata key-value will be passed along the link
        transitive:
          - CUSTOM-METADATA-KEY-TRANSITIVE

Verify

Request Invoke

curl -L -X GET 'http://127.0.0.1:48080/metadata/service/caller/feign/info'

Expected return rate

{
  "caller-metadata-contents": {
    "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE",
    "CUSTOM-METADATA-KEY-LOCAL": "CUSTOM-VALUE-LOCAL"
  },
  "callee-transitive-metadata": {
    "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
  },
  "caller-transitive-metadata": {
    "CUSTOM-METADATA-KEY-TRANSITIVE": "CUSTOM-VALUE-TRANSITIVE"
  }
}

Response value description

  • Key caller-metadata-contents represents all metadata configured by default in the metadata-caller-service project.
  • Key caller-transitive-metadata represents the list of metadata that can be passed in the link specified in the metadata-caller-service item.
  • Key callee-transitive-metadata represents the list of upstream metadata passed when the metadata-callee-service project is called by metadata-caller-service.

Wiki Reference

See Spring Cloud Tencent Metadata Transfer Usage Document for more reference .