Camel Netty负载平衡器-未收到任何响应异常

时间:2018-06-19 20:50:57

标签: apache-camel

我正在使用Apache Camel,Netty4组件和负载平衡遇到意外的CamelExchangeException。在代码正常运行并返回响应的同时,当Netty连接关闭时,骆驼仍然在最后一次交换上抛出CamelExchangeException

 from("netty4:tcp://localhost:9090?sync=true&textline=true")
      .setBody(simple("pong"))
      .setHeader(NettyConstants.NETTY_CLOSE_CHANNEL_WHEN_COMPLETE, simple("true", Boolean.class));

 from("timer:foo?delay=10000")
      .to("log:inbound?showAll=true")
      .process((Exchange exchange) -> {
           exchange.getIn().setBody("ping");
       })
       .loadBalance(new LoadBalancer())
       .to("netty4:tcp://localhost:9090?sync=true&textline=true")
       .end()
       .to("log:outbound?showAll=true");

这是负载均衡器

public class LoadBalancer extends SimpleLoadBalancerSupport {
    @Override
    public void process(Exchange exchange) throws Exception {
        this.getProcessors().get(0).process(exchange);
    }
}

例外

org.apache.camel.CamelExchangeException: No response received from remote server: localhost:9090. Exchange[ID-DESKTOP-6JJUOT9-1529441233240-0-21]
at org.apache.camel.component.netty4.handlers.ClientChannelHandler.channelInactive(ClientChannelHandler.java:133)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.channel.ChannelInboundHandlerAdapter.channelInactive(ChannelInboundHandlerAdapter.java:75)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.handler.codec.ByteToMessageDecoder.channelInputClosed(ByteToMessageDecoder.java:377)
at io.netty.handler.codec.ByteToMessageDecoder.channelInactive(ByteToMessageDecoder.java:342)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.AbstractChannelHandlerContext.fireChannelInactive(AbstractChannelHandlerContext.java:224)
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelInactive(DefaultChannelPipeline.java:1409)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:245)
at io.netty.channel.AbstractChannelHandlerContext.invokeChannelInactive(AbstractChannelHandlerContext.java:231)
at io.netty.channel.DefaultChannelPipeline.fireChannelInactive(DefaultChannelPipeline.java:927)
at io.netty.channel.AbstractChannel$AbstractUnsafe$8.run(AbstractChannel.java:822)
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:163)
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:404)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:463)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:886)
at java.lang.Thread.run(Thread.java:745)

如果卸下负载均衡器或保持连接打开,则不会引发相同的异常。

骆驼版本2.21.1

0 个答案:

没有答案