升级到2.6.0版本发现filter逻辑是在网络线程,不是在业务线程,如果业务通过扩展filter获取业务线程上下文,当前2.6版本之后无法获取
https://github.com/apache/servicecomb-java-chassis/blob/703a972576b35154d9a9a46f087411fab86fd74a/transports/transport-rest/transport-rest-client/src/main/java/org/apache/servicecomb/transport/rest/client/http/RestClientInvocation.java#L123
你这个获取的时候要在哪里获取呢,是下游微服务吗还是说后面的某个特定位置。
能给看一下你是如何在filter里面获取上下文并添加内容的吗?
我这里直接是可以取到框架的上下文的。
是在业务线程中设置ThreadLocal数据,在Filter中无法获取到数据。 @RequestMapping(value = "/user", method = RequestMethod.GET) public String userInfo(@RequestParam(value = "name", required = true) String name) {
ContextInterceptor.setContextCachethreadLocal(10000989);
…… public class ContextInterceptor {
private static final ThreadLocal<Integer> threadLocal = new ThreadLocal<>();
…… public class CseTest implements HttpClientFilter {
@Override
public int getOrder() {
return 0;
}
@Override
public void beforeSendRequest(Invocation invocation, HttpServletRequestEx requestEx) {
System.out.println("threadLocal=" + ContextInterceptor.getContextCachethreadLocal());
这里获取为空
Add a PR to use async implicitly. see https://github.com/apache/servicecomb-java-chassis/pull/3291/files