Camel-ahc-ws netty运行时异常

时间:2016-10-26 12:54:27

标签: spring-boot websocket apache-camel

使用以下依赖项

compile('org.apache.camel:camel-jackson:2.18.0')
compile('org.apache.camel:camel-metrics:2.18.0')
compile('org.apache.camel:camel-spring-boot-starter:2.18.0')
compile('org.apache.camel:camel-spring-redis:2.18.0')
compile('org.apache.camel:camel-stream:2.18.0')
compile('org.apache.camel:camel-ahc-ws:2.18.0')
compile('org.springframework.boot:spring-boot-actuator')
compile("org.springframework.boot:spring-boot-starter-web")

以及Spring Boot中的以下ahc-ws定义

.........
.multicast()
.parallelProcessing()

.pipeline()
.marshal().json(JsonLibrary.Jackson)
.convertBodyTo(String.class)  // Avoids string serialization issues in websocket component.
.to("ahc-ws://localhost:8080/votes?sendToAll=true")
.end()
.........

在运行时,发布到此接收器时出现以下错误

2016-10-25 11:41:45.689  INFO 1864 --- [ #7 - Multicast] o.a.camel.component.ahc.ws.WsEndpoint    : Reconnecting websocket: ws://localhost:8080/votes?sendToAll=true
2016-10-25 11:41:45.777 ERROR 1864 --- [ #7 - Multicast] o.a.camel.processor.DefaultErrorHandler  : Failed delivery for (MessageId: ID-singram-mint172-42019-1477410101007-0-56 on ExchangeId: ID-singram-mint172-42019-1477410101007-0-59). Exhausted after delivery attempt: 1 caught: java.util.concurrent.ExecutionException: java.net.ConnectException: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;

java.util.concurrent.ExecutionException: java.net.ConnectException: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;
        at org.asynchttpclient.netty.NettyResponseFuture.abort(NettyResponseFuture.java:239) ~[async-http-client-2.0.15.jar:na]
        at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:162) ~[async-http-client-2.0.15.jar:na]
        at org.asynchttpclient.netty.request.NettyChannelConnector$1.onFailure(NettyChannelConnector.java:103) ~[async-http-client-2.0.15.jar:na]
        at org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:28) ~[async-http-client-2.0.15.jar:na]
        at org.asynchttpclient.netty.SimpleChannelFutureListener.operationComplete(SimpleChannelFutureListener.java:20) ~[async-http-client-2.0.15.jar:na]
        at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:514) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:488) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.util.concurrent.DefaultPromise.access$000(DefaultPromise.java:34) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.util.concurrent.DefaultPromise$1.run(DefaultPromise.java:438) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.util.concurrent.GlobalEventExecutor$TaskRunner.run(GlobalEventExecutor.java:233) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at java.lang.Thread.run(Thread.java:745) [na:1.8.0_91] Caused by: java.net.ConnectException: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;
        at org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:160) ~[async-http-client-2.0.15.jar:na]
        ... 10 common frames omitted
Caused by: java.lang.NoSuchMethodError: io.netty.channel.DefaultChannelId.newInstance()Lio/netty/channel/DefaultChannelId;
        at io.netty.channel.AbstractChannel.newId(AbstractChannel.java:107) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.AbstractChannel.<init>(AbstractChannel.java:79) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.nio.AbstractNioChannel.<init>(AbstractNioChannel.java:84) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.nio.AbstractNioByteChannel.<init>(AbstractNioByteChannel.java:54) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:98) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:88) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:81) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.channel.socket.nio.NioSocketChannel.<init>(NioSocketChannel.java:74) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at org.asynchttpclient.netty.channel.NioSocketChannelFactory.newChannel(NioSocketChannelFactory.java:25) ~[async-http-client-2.0.15.jar:na]
        at org.asynchttpclient.netty.channel.NioSocketChannelFactory.newChannel(NioSocketChannelFactory.java:19) ~[async-http-client-2.0.15.jar:na]
        at io.netty.bootstrap.AbstractBootstrap.initAndRegister(AbstractBootstrap.java:319) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.bootstrap.Bootstrap.doResolveAndConnect(Bootstrap.java:163) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]
        at io.netty.bootstrap.Bootstrap.connect(Bootstrap.java:156) ~[netty-all-4.1.5.Final.jar:4.1.5.Final]

对于正在发生/遗失的事情的任何想法?

我注意到依赖树有点奇怪,因为netty-all(见下)是4.1.5而所有其他netty依赖都是4.0.41。这是使用&#39; gradle依赖&#39;

生成的
+--- org.apache.camel:camel-ahc-ws:2.18.0
|    +--- org.apache.camel:camel-core:2.18.0 (*)
|    \--- org.apache.camel:camel-ahc:2.18.0
|         +--- org.apache.camel:camel-core:2.18.0 (*)
|         +--- org.asynchttpclient:async-http-client:2.0.15
|         |    +--- org.asynchttpclient:async-http-client-netty-utils:2.0.15
|         |    |    +--- io.netty:netty-buffer:4.0.41.Final
|         |    |    |    \--- io.netty:netty-common:4.0.41.Final
|         |    |    \--- org.slf4j:slf4j-api:1.7.21
|         |    +--- io.netty:netty-codec-http:4.0.41.Final
|         |    |    +--- io.netty:netty-codec:4.0.41.Final
|         |    |    |    \--- io.netty:netty-transport:4.0.41.Final
|         |    |    |         \--- io.netty:netty-buffer:4.0.41.Final (*)
|         |    |    \--- io.netty:netty-handler:4.0.41.Final
|         |    |         +--- io.netty:netty-buffer:4.0.41.Final (*)
|         |    |         +--- io.netty:netty-transport:4.0.41.Final (*)
|         |    |         \--- io.netty:netty-codec:4.0.41.Final (*)
|         |    +--- io.netty:netty-transport-native-epoll:4.0.41.Final
|         |    |    +--- io.netty:netty-common:4.0.41.Final
|         |    |    +--- io.netty:netty-buffer:4.0.41.Final (*)
|         |    |    \--- io.netty:netty-transport:4.0.41.Final (*)
|         |    +--- org.asynchttpclient:netty-resolver-dns:2.0.15
|         |    |    +--- org.asynchttpclient:netty-resolver:2.0.15
|         |    |    |    +--- io.netty:netty-common:4.0.41.Final
|         |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|         |    |    +--- org.asynchttpclient:netty-codec-dns:2.0.15
|         |    |    |    +--- io.netty:netty-codec:4.0.41.Final (*)
|         |    |    |    \--- org.slf4j:slf4j-api:1.7.21
|         |    |    +--- io.netty:netty-transport:4.0.41.Final (*)
|         |    |    \--- org.slf4j:slf4j-api:1.7.21
|         |    +--- org.reactivestreams:reactive-streams:1.0.0
|         |    +--- com.typesafe.netty:netty-reactive-streams:1.0.7
|         |    |    +--- io.netty:netty-handler:4.0.39.Final -> 4.0.41.Final (*)
|         |    |    \--- org.reactivestreams:reactive-streams:1.0.0
|         |    +--- org.javassist:javassist:3.20.0-GA
|         |    \--- org.slf4j:slf4j-api:1.7.21
|         \--- io.netty:netty-all:4.1.5.Final

1 个答案:

答案 0 :(得分:0)

尝试排除netty-all 4.1.5并包含netty-all 4.0.41.Final。 这有助于我克服这些错误。

我要为此打开骆驼的缺陷,因为我相信你是正确的先生:它确实是一个&#34;奇怪的&#34;依赖树:)

https://issues.apache.org/jira/browse/CAMEL-10465