CAMEL-7998 Just call bind if it's UdpConnectionlessSending
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d69601b2 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d69601b2 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d69601b2 Branch: refs/heads/master Commit: d69601b2371410001393155b17c78772df819dee Parents: dd91390 Author: Willem Jiang <willem.ji...@gmail.com> Authored: Tue Nov 11 11:41:54 2014 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Tue Nov 11 11:43:37 2014 +0800 ---------------------------------------------------------------------- .../java/org/apache/camel/component/netty/NettyProducer.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/d69601b2/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java index 8d54f0a..e317e76 100644 --- a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java +++ b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyProducer.java @@ -403,10 +403,7 @@ public class NettyProducer extends DefaultAsyncProducer { // set the pipeline factory, which creates the pipeline for each newly created channels connectionlessClientBootstrap.setPipelineFactory(pipelineFactory); - // bind and store channel so we can close it when stopping - Channel channel = connectionlessClientBootstrap.bind(new InetSocketAddress(0)); - - allChannels.add(channel); + // if udp connectionless sending is true we don't do a connect. // we just send on the channel created with bind which means // really fire and forget. You wont get an PortUnreachableException @@ -414,6 +411,9 @@ public class NettyProducer extends DefaultAsyncProducer { if (!configuration.isUdpConnectionlessSending()) { answer = connectionlessClientBootstrap.connect(new InetSocketAddress(configuration.getHost(), configuration.getPort())); } else { + // bind and store channel so we can close it when stopping + Channel channel = connectionlessClientBootstrap.bind(new InetSocketAddress(0)); + allChannels.add(channel); answer = new SucceededChannelFuture(channel); }