ruanwenjun commented on pull request #8263:
URL: 
https://github.com/apache/dolphinscheduler/pull/8263#issuecomment-1028588998


   > > It seems this pr doesn't solve the callback issue? When we use an async 
request, we hope the callback function can be trigger when the result return.
   > 
   > it's already implemented by NettyClientHandler,when the result return by 
channel with netty, it will trigger the channelRead() and then call the 
readHandler() to judge the method is async or not. the original code is below
   > 
   > ```java
   >     private void readHandler(RpcResponse rsp, RpcRequestCache rpcRequest, 
long reqId) {
   >         String serviceName = rpcRequest.getServiceName();
   >         ConsumerConfig consumerConfig = 
ConsumerConfigCache.getConfigByServersName(serviceName);
   >         if (Boolean.FALSE.equals(consumerConfig.getAsync())) {
   >             RpcFuture future = rpcRequest.getRpcFuture();
   >             RpcRequestTable.remove(reqId);
   >             future.done(rsp);
   >             return;
   >         }
   > 
   >         if (Boolean.FALSE.equals(consumerConfig.getCallBack())) {
   >             return;
   >         }
   > 
   >         if (rsp.getStatus() == 0) {
   > 
   >             try {
   >                 
consumerConfig.getServiceCallBackClass().getDeclaredConstructor().newInstance().run(rsp.getResult());
   >             } catch (InstantiationException | IllegalAccessException | 
NoSuchMethodException | InvocationTargetException e) {
   >                 logger.error("rpc service call back error,serviceName 
{},rsp {}", serviceName, rsp);
   >             }
   >         } else {
   >             logger.error("rpc response error ,serviceName {},rsp {}", 
serviceName, rsp);
   >         }
   > 
   >     }
   > ```
   
   Yes, I see, this can work well now.


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


Reply via email to