fanjiwang1992 edited a comment on issue #2596:
URL:
https://github.com/apache/servicecomb-java-chassis/issues/2596#issuecomment-926500593
客户端设置方式:
第一种: 通过ContextUtils直接获取invocationContext
InvocationContext invocationContext =
ContextUtils.getInvocationContext();
invocationContext.addContext("csefjw", "ddddd");
第二种: 直接new InvocationContext() 放进CseHttpEntity中
InvocationContext invocationContext = new InvocationContext();
CseHttpEntity<?> entity = new CseHttpEntity<>(null)
entity.setContext(invocationContext);
服务端获取方式:
第一种: 通过ContextUtils直接获取invocationContext
InvocationContext invocationContext = ContextUtils.getInvocationContext()
invocationContext .getContext()或者指定具体的key
第二种: 在接口参数中添加 InvocationContext invocationContext
public String sayHello(@PathVariable("name") @Length String name,
InvocationContext invocationContext) throws InterruptedException {
System.out.println(invocationContext.getContext().get("aaa"));
System.out.println(formatter.format(new Date())+ " " +name);
return name+", hello";
}
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]