You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/11/24 01:01:24 UTC

[GitHub] [dubbo] fl061157 commented on issue #9299: DUBBO 2.7.11 版本Consumer 端响应丢失

fl061157 commented on issue #9299:
URL: https://github.com/apache/dubbo/issues/9299#issuecomment-977340810


   @zrlw  嗯, 后面我们替换了 。     String DISPATCHER_KEY = "dispatcher";  扩展了一下,也是包住了异常,就没有在复现。   
   
   
   public class DubboRequestDispatcher implements Dispatcher {
   
       @Override
       public ChannelHandler dispatch(ChannelHandler handler, URL url) {
           return new DubboRequestChannelHandler(handler , url);
       }
   }
   
   
   
   public class DubboRequestChannelHandler extends WrappedChannelHandler {
   
       private final static Logger LOGGER = LoggerFactory.getLogger(DubboRequestChannelHandler.class);
   
       public final static Executor REQUEST_EXEC = //;
   
       public DubboRequestChannelHandler(ChannelHandler handler, URL url) {
           super(handler, url);
       }
   
       @Override
       public void connected(Channel channel) throws RemotingException {
           try {
               Runnable runnable = new ChannelEventRunnable(channel, handler, ChannelEventRunnable.ChannelState.CONNECTED);
               InnerRunnableWrapper rw = new InnerRunnableWrapper(runnable);
               REQUEST_EXEC.execute(rw);
           } catch (Throwable t) {
               throw new ExecutionException("connect event", channel, getClass() + " error when process connected event .", t);
           }
       }
   
       @Override
       public void disconnected(Channel channel) throws RemotingException {
           try {
               Runnable runnable = new ChannelEventRunnable(channel, handler, ChannelEventRunnable.ChannelState.DISCONNECTED);
               InnerRunnableWrapper rw = new InnerRunnableWrapper(runnable);
               REQUEST_EXEC.execute(rw);
           } catch (Throwable t) {
               throw new ExecutionException("disconnect event", channel, getClass() + " error when process disconnected event .", t);
           }
       }
   
       @Override
       public void received(Channel channel, Object message) throws RemotingException {
           try {
               Runnable runnable = new ChannelEventRunnable(channel, handler, ChannelEventRunnable.ChannelState.RECEIVED, message);
               InnerRunnableWrapper rw = new InnerRunnableWrapper(runnable);
               REQUEST_EXEC.execute(rw);
           } catch (Throwable t) {
               if (message instanceof Request && t instanceof RejectedExecutionException) {
                   sendFeedback(channel, (Request) message, t);
                   return;
               }
               throw new ExecutionException(message, channel, getClass() + " error when process received event .", t);
           }
       }
   
       @Override
       public void caught(Channel channel, Throwable exception) throws RemotingException {
           try {
               Runnable runnable = new ChannelEventRunnable(channel, handler, ChannelEventRunnable.ChannelState.CAUGHT, exception);
               InnerRunnableWrapper rw = new InnerRunnableWrapper(runnable);
               REQUEST_EXEC.execute(rw);
           } catch (Throwable t) {
               throw new ExecutionException("caught event", channel, getClass() + " error when process caught event .", t);
           }
       }
   
       private static class InnerRunnableWrapper implements Runnable {
   
           private Runnable runnable;
   
           public InnerRunnableWrapper(Runnable runnable) {
               this.runnable = runnable;
           }
   
           @Override
           public void run() {
               try {
                   runnable.run();
               } catch (Throwable throwable) {
                   LOGGER.error("run channelHandler error.", throwable);
               }
           }
       }
   
   }
   
   
   


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org