qingliu
f5ec25ee57
|
2 years ago | |
---|---|---|
.. | ||
metadata-callee-service | 2 years ago | |
metadata-caller-service | 2 years ago | |
README-zh.md | 3 years ago | |
README.md | 3 years ago | |
pom.xml | 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-service
、metadata-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-service
‘sMetadataCalleeService
-
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-service
、metadata-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 themetadata-caller-service
project. - Key
caller-transitive-metadata
represents the list of metadata that can be passed in the link specified in themetadata-caller-service
item. - Key
callee-transitive-metadata
represents the list of upstream metadata passed when themetadata-callee-service
project is called bymetadata-caller-service
.
Wiki Reference
See Spring Cloud Tencent Metadata Transfer Usage Document for more reference .