Repository: camel Updated Branches: refs/heads/master fd02839e5 -> 33d0b0df3
CAMEL-6934 enabling dns addresses to not get cached Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/3c3f4f03 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/3c3f4f03 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/3c3f4f03 Branch: refs/heads/master Commit: 3c3f4f03d3b04102c6fbab88e713136bd444a186 Parents: 46b5128 Author: Rob Shield <rob.c.shi...@googlemail.com> Authored: Sun Dec 1 13:30:44 2013 +0000 Committer: Rob Shield <rob.c.shi...@googlemail.com> Committed: Sun Dec 1 13:30:44 2013 +0000 ---------------------------------------------------------------------- .../camel/component/mina2/Mina2Configuration.java | 15 ++++++++++++++- .../apache/camel/component/mina2/Mina2Producer.java | 13 +++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/3c3f4f03/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java ---------------------------------------------------------------------- diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java index 245de3c..2e0b2e3 100644 --- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java +++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Configuration.java @@ -53,6 +53,7 @@ public class Mina2Configuration implements Cloneable { private boolean autoStartTls = true; private int maximumPoolSize = 16; // 16 is the default mina setting private boolean orderedThreadPoolExecutor = true; + private boolean cachedAddress = true; /** * Returns a copy of this configuration @@ -263,7 +264,19 @@ public class Mina2Configuration implements Cloneable { public void setOrderedThreadPoolExecutor(boolean orderedThreadPoolExecutor) { this.orderedThreadPoolExecutor = orderedThreadPoolExecutor; } - + + public void setCachedAddress(boolean shouldCacheAddress){ + this.cachedAddress = shouldCacheAddress; + } + + public boolean getCachedAddress(){ + return this.cachedAddress; + } + + public boolean isCachedAddress(){ + return this.getCachedAddress(); + } + // here we just shows the option setting of host, port, protocol public String getUriString() { return "mina2:" + getProtocol() + ":" + getHost() + ":" + getPort(); http://git-wip-us.apache.org/repos/asf/camel/blob/3c3f4f03/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java ---------------------------------------------------------------------- diff --git a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java index ba41f18..fc7c493 100644 --- a/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java +++ b/components/camel-mina2/src/main/java/org/apache/camel/component/mina2/Mina2Producer.java @@ -251,6 +251,9 @@ public class Mina2Producer extends DefaultProducer implements ServicePoolAware { } private void openConnection() { + if(this.address == null || !this.configuration.isCachedAddress()){ + setSocketAddress(this.configuration.getProtocol()); + } if (LOG.isDebugEnabled()) { LOG.debug("Creating connector to address: {} using connector: {} timeout: {} millis.", new Object[]{address, connector, timeout}); } @@ -447,6 +450,16 @@ public class Mina2Producer extends DefaultProducer implements ServicePoolAware { } } + private void setSocketAddress(String protocol){ + if(protocol.equals("tcp")){ + this.address = new InetSocketAddress(configuration.getHost(), configuration.getPort()); + }else if(configuration.isDatagramProtocol()){ + this.address = new InetSocketAddress(configuration.getHost(), configuration.getPort()); + }else if(protocol.equals("vm")){ + this.address = new VmPipeAddress(configuration.getPort()); + } + } + /** * Handles response from session writes */