zrlw edited a comment on issue #8567:
URL: https://github.com/apache/dubbo/issues/8567#issuecomment-904321568


   也可以变通一下解决这个问题:
   在DubboReference注解上加 
parameters参数,同一个服务接口不同的Reference注解定义不同的参数,比如定义一个process参数,clientA用proc-a, 
clientB用proc-b:
   ```
   ClientA.java:
   @DubboReference( parameters = {"process", "proc-a"}, ...)
   DubboService s;
   ...
   ClientB.java:
   @DubboReference( parameters = {"process", "proc-b"}, ...)
   DubboService s;
   ```
   
clientA和clientB的回调方法放到统一的门面组件里,回调方法依据rpccontext的consumerUrl里取出process参数分别进行处理,比如:
   ```
   String process = 
RpcContext.getContext().getConsumerUrl.getParameter("process");
   switch (process) {
       case "proc-a": ....
       case "proc-b": ....
   }
   ```
   要从consumerUrl的parameters里取出DubboReference注解定义的process参数的原因如下:
   1. 如果DubboReference注解设置了async=true, 
无论consumerUrl还是url的parameters都有process参数,parameters里面的side属性值都是consumer;
   2. 
如果DubboReference注解里没设置async=true,那么只有oninvoke方法执行时获得的rpcContext的url还有process参数,url的parameters里面的side属性值还是consumer,其他两个回调方法onreturn和onthrow获得的rpcContext的url里面没有process参数,而且parameters里面的side属性值是provider,而consumerUrl里面有process参数,consumerUrl里的side属性也一直都是consumer。


-- 
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]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to