You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by GitBox <gi...@apache.org> on 2018/07/04 00:57:40 UTC

[GitHub] windywang edited a comment on issue #1423: Tracing order shows error when I use hystrix before dubbo

windywang edited a comment on issue #1423:  Tracing order shows error when I use hystrix before dubbo 
URL: https://github.com/apache/incubator-skywalking/issues/1423#issuecomment-402331985
 
 
   @wu-sheng   
   dubbo filter:  
   
   @Activate(group = Constants.CONSUMER, before = "future")
   public class HystrixFilter implements Filter {
       private static final Logger logger = LoggerFactory.getLogger(HystrixFilter.class);
       private ThreadPoolConfig  threadPoolConfig;
       private DubboHystrixCommandConfig dubboHystrixCommandConfig;
       public void setThreadPoolConfig(ThreadPoolConfig threadPoolConfig) {
           this.threadPoolConfig = threadPoolConfig;
       }
       public void setDubboHystrixCommandConfig(DubboHystrixCommandConfig dubboHystrixCommandConfig) {
           this.dubboHystrixCommandConfig = dubboHystrixCommandConfig;
       }
       @Override
       public Result invoke(Invoker<?> invoker, Invocation invocation) throws RpcException {
           URL url = invoker.getUrl();
           String methodName = invocation.getMethodName();
           String interfaceName = invoker.getInterface().getName();
           HystrixCommand.Setter setter = HystrixCommandSetterFactory.create(interfaceName, methodName, url, threadPoolConfig, dubboHystrixCommandConfig);
           String fallback = url.getMethodParameter(methodName, "fallback");
           DubboCommand command = new DubboCommand(setter, invoker, invocation, fallback,RpcContext.getContext());
           Result result = command.execute();
           return result;
       }
   }
   
   
   DubooCommand :
   
   public class DubboCommand extends HystrixCommand<Result> {
       private Invoker<?> invoker;
       private Invocation invocation;
       private String fallbackName;
       private RpcContext rpcContext;
   
       public DubboCommand(Setter setter, Invoker<?> invoker, Invocation invocation, String fallbackName, RpcContext rpcContext) {
           super(setter);
           this.invoker = invoker;
           this.invocation = invocation;
           this.fallbackName = fallbackName;
           this.rpcContext = rpcContext;
       }
       @Override
       protected Result run() throws Exception {
           RpcContext.getContext().setAttachments(rpcContext.getAttachments());
           Result result = invoker.invoke(invocation);
           if (result.hasException()) {
               throw (Exception) result.getException();
           }
           return result;
       }

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services