ServiceComb provides a Context to delivery data between microservices. Context is a key/value pair and can only use data of type String. Since the Context is serialized into the Json format and passed through the HTTP header, characters other than ASCII are not supported. Other characters require the developer to encode and pass the code. The Context is passed on the request chain in a single request and does not need to be reset. The functions such as trace id of access log are implemented based on this feature.
The Handler contains the Invocation object, which can be called directly in the invocation.addContext and invocation.getContext settings.
Inject through the interface
public Response cseResponse(InvocationContext c1)
or
ContextUtils.getInvocationContext()
By override EdgeInvocation
EdgeInvocation edgeInvocation = new EdgeInvocation() {
protected void createInvocation() {
super.createInvocation();
this.invocation.addContext("hello", "world");
}
};