我有一个消费来自 netty:udp 的Apache Camel路由,可选择将UDP响应发送回UDP客户端(如果请求),并生成Kafka主题。我偶尔会得到以下 java.net.SocketException ,这会导致netty停止侦听配置的UDP端口。我想我的问题是所有套接字代码都是camel-netty,这似乎是一个严重的问题(即停止路由的关联netty UDP侦听器,我已经通过Linux netstat命令验证了这一点。)
我正在使用 -Djava.net.preferIPv4Stack = true 测试JVM执行情况,正如其他帖子推荐的那样, 但我担心的是“无效参数”SocketException不经常发生,所以不确定 设置 -Djava.net.preferIPv4Stack = true 会真正解决问题吗?
我想知道升级到 camel-netty4 是否能解决这个问题?我没有写过我自己的套接字代码,这些都是Camel / netty。
我在使用Java 1.7和RHEL-6的Linux物理服务器上运行。任何想法都非常感谢!!!
这是我的路线XML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<route startupOrder="104" customId="true" id="ROUTE_ID_RAW_DTC_EVENTS" xmlns="http://camel.apache.org/schema/spring">
<from uri="netty:udp://talend-es-edge-01.kiad0.s.mission.net:62265?serverPipelineFactory=#DTC_SERVER_PIPELINE_FACTORY_ROUTE_ID_RAW_DTC_EVENTS&keepAlive=true&sync=true&orderedThreadPoolExecutor=false&receiveBufferSize=8388608&sendBufferSize=8388608&allowDefaultCodec=false&disconnectOnNoReply=false&receiveBufferSizePredictor=8192"/>
<setProperty propertyName="CamelCharsetName" id="setProperty10">
<expressionDefinition>iso-8859-1</expressionDefinition>
</setProperty>
<threads poolSize="7" maxPoolSize="14" threadName="threads_ROUTE_ID_RAW_DTC_EVENTS" callerRunsWhenRejected="true" id="threads3">
<wireTap uri="netty:udp://abinitio-edge-02.kiad0.s.mission.net:62265?clientPipelineFactory=#DTC_CLIENT_PIPELINE_FACTORY_ROUTE_ID_RAW_DTC_EVENTS&sync=false&sendBufferSize=8388608&allowDefaultCodec=false" customId="true" id="ROUTE_ID_RAW_DTC_EVENTS_MIRROR"/>
<multicast parallelProcessing="true" id="multicast3">
<to uri="seda:SEDA_TOP_102?size=100000&concurrentConsumers=10&waitForTaskToComplete=Never&failIfNoConsumers=true&timeout=10000" id="to8"/>
<to uri="seda:SEDA_ACK_103?size=100000&concurrentConsumers=10&waitForTaskToComplete=IfReplyExpected&failIfNoConsumers=true&timeout=10000" customId="true" id="ROUTE_ID_RAW_DTC_EVENTS_TO_FIRST_URIS"/>
<setProperty propertyName="CamelCharsetName" id="setProperty11">
<expressionDefinition>iso-8859-1</expressionDefinition>
</setProperty>
</multicast>
</threads>
</route>
这是显示SocketException的堆栈跟踪:
java.nio.channels.ClosedChannelException
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.cleanUpWriteBuffer(AbstractNioWorker.java:433) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.writeFromUserCode(NioDatagramWorker.java:212) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramPipelineSink.eventSunk(NioDatagramPipelineSink.java:97) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:779) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.Channels.write(Channels.java:725) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.doEncode(OneToOneEncoder.java:71) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.handler.codec.oneone.OneToOneEncoder.handleDownstream(OneToOneEncoder.java:59) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:591) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:582) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.Channels.write(Channels.java:704) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:252) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramChannel.write(NioDatagramChannel.java:299) ~[netty-3.9.6.Final.jar:?]
at org.apache.camel.component.netty.NettyHelper.writeBodyAsync(NettyHelper.java:93) [camel-netty-2.15.2.jar:2.15.2]
at org.apache.camel.component.netty.NettyProducer.process(NettyProducer.java:263) [camel-netty-2.15.2.jar:2.15.2]
at org.apache.camel.processor.RedeliveryErrorHandler.process(RedeliveryErrorHandler.java:448) [camel-core-2.15.2.jar:2.15.2]
at org.apache.camel.processor.CamelInternalProcessor.process(CamelInternalProcessor.java:191) [camel-core-2.15.2.jar:2.15.2]
at org.apache.camel.util.AsyncProcessorHelper.process(AsyncProcessorHelper.java:109) [camel-core-2.15.2.jar:2.15.2]
at org.apache.camel.processor.DelegateAsyncProcessor.process(DelegateAsyncProcessor.java:87) [camel-core-2.15.2.jar:2.15.2]
at org.apache.camel.processor.WireTapProcessor$1.call(WireTapProcessor.java:119) [camel-core-2.15.2.jar:2.15.2]
at org.apache.camel.processor.WireTapProcessor$1.call(WireTapProcessor.java:113) [camel-core-2.15.2.jar:2.15.2]
at java.util.concurrent.FutureTask.run(FutureTask.java:262) [?:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_75]
[2015-09-04 21:45:02,532] WARN [New I/O worker #49] Caused by: [org.apache.camel.CamelExchangeException - Cannot write response to /188.122.39.102:0. Exchange[Message: ]. Caused by: [java.net.SocketException - Invalid argument]]
org.apache.camel.CamelExchangeException: Cannot write response to /188.122.39.102:0. Exchange[Message: ]. Caused by: [java.net.SocketException - Invalid argument]
at org.apache.camel.component.netty.handlers.ServerResponseFutureListener.operationComplete(ServerResponseFutureListener.java:53) [camel-netty-2.15.2.jar:2.15.2]
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:431) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:417) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:384) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.write0(NioDatagramWorker.java:319) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromTaskLoop(AbstractNioWorker.java:151) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioChannel$WriteTask.run(AbstractNioChannel.java:335) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.run(NioDatagramWorker.java:343) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) [netty-3.9.6.Final.jar:?]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) [netty-3.9.6.Final.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_75]
Caused by: java.net.SocketException: Invalid argument
at sun.nio.ch.DatagramChannelImpl.send0(Native Method) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:532) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:494) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:473) ~[?:1.7.0_75]
at org.jboss.netty.channel.socket.nio.SocketSendBufferPool$UnpooledSendBuffer.transferTo(SocketSendBufferPool.java:207) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.write0(NioDatagramWorker.java:281) ~[netty-3.9.6.Final.jar:?]
... 11 more
[2015-09-04 21:45:02,535] WARN [pool-17-thread-23] Closing channel as an exception was thrown from Netty. Caused by: [java.net.SocketException - Invalid argument]
java.net.SocketException: Invalid argument
at sun.nio.ch.DatagramChannelImpl.send0(Native Method) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.sendFromNativeBuffer(DatagramChannelImpl.java:532) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:494) ~[?:1.7.0_75]
at sun.nio.ch.DatagramChannelImpl.send(DatagramChannelImpl.java:473) ~[?:1.7.0_75]
at org.jboss.netty.channel.socket.nio.SocketSendBufferPool$UnpooledSendBuffer.transferTo(SocketSendBufferPool.java:207) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.write0(NioDatagramWorker.java:281) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromTaskLoop(AbstractNioWorker.java:151) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioChannel$WriteTask.run(AbstractNioChannel.java:335) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.channel.socket.nio.NioDatagramWorker.run(NioDatagramWorker.java:343) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) ~[netty-3.9.6.Final.jar:?]
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42) ~[netty-3.9.6.Final.jar:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [?:1.7.0_75]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [?:1.7.0_75]
at java.lang.Thread.run(Thread.java:745) [?:1.7.0_75]
答案 0 :(得分:0)
我一直在使用camel-netty4 UDP,现在没有这样的问题。我建议你使用camel-netty4除非你有一些令人信服的理由坚持使用camel-netty(netty3)