Repository: camel Updated Branches: refs/heads/camel-2.15.x b8f18ea6b -> 91fbaa449
CAMEL-9514 Fixed the issue that camel-netty4 maximumPoolSize option is ignored Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/91fbaa44 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/91fbaa44 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/91fbaa44 Branch: refs/heads/camel-2.15.x Commit: 91fbaa4490e5fbd195f2cf5f5c1b44e58425bd3a Parents: b8f18ea Author: Willem Jiang <willem.ji...@gmail.com> Authored: Mon Jan 18 13:50:39 2016 +0800 Committer: Willem Jiang <willem.ji...@gmail.com> Committed: Mon Jan 18 13:50:39 2016 +0800 ---------------------------------------------------------------------- .../camel/component/netty4/NettyComponent.java | 24 ++++++++++++++++---- .../component/netty4/NettyConfiguration.java | 10 -------- 2 files changed, 20 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/91fbaa44/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyComponent.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyComponent.java index 66ba640..8799719 100644 --- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyComponent.java +++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyComponent.java @@ -32,6 +32,7 @@ import org.apache.camel.util.concurrent.CamelThreadFactory; public class NettyComponent extends UriEndpointComponent { private NettyConfiguration configuration; + private int maximumPoolSize = 16; private volatile EventExecutorGroup executorService; public NettyComponent() { @@ -46,6 +47,19 @@ public class NettyComponent extends UriEndpointComponent { super(context, NettyEndpoint.class); } + public int getMaximumPoolSize() { + return maximumPoolSize; + } + + /** + * The thread pool size for the EventExecutorGroup if its in use. + * <p/> + * The default value is 16. + */ + public void setMaximumPoolSize(int maximumPoolSize) { + this.maximumPoolSize = maximumPoolSize; + } + @Override protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception { NettyConfiguration config; @@ -108,7 +122,8 @@ public class NettyComponent extends UriEndpointComponent { if (configuration == null) { configuration = new NettyConfiguration(); } - + + //Only setup the executorService if it is needed if (configuration.isUsingExecutorService() && executorService == null) { executorService = createExecutorService(); } @@ -122,13 +137,14 @@ public class NettyComponent extends UriEndpointComponent { // we should use a shared thread pool as recommended by Netty String pattern = getCamelContext().getExecutorServiceManager().getThreadNamePattern(); ThreadFactory factory = new CamelThreadFactory(pattern, "NettyEventExecutorGroup", true); - return new DefaultEventExecutorGroup(configuration.getMaximumPoolSize(), factory); + return new DefaultEventExecutorGroup(getMaximumPoolSize(), factory); } @Override protected void doStop() throws Exception { - if (executorService != null) { + //Only shutdown the executorService if it is created by netty component + if (configuration.isUsingExecutorService() && executorService != null) { getCamelContext().getExecutorServiceManager().shutdownNow(executorService); executorService = null; } @@ -136,4 +152,4 @@ public class NettyComponent extends UriEndpointComponent { super.doStop(); } -} \ No newline at end of file +} http://git-wip-us.apache.org/repos/asf/camel/blob/91fbaa44/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java ---------------------------------------------------------------------- diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java index 2e2244d..67f163f 100644 --- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java +++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java @@ -76,8 +76,6 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem private boolean allowDefaultCodec = true; @UriParam private ClientInitializerFactory clientInitializerFactory; - @UriParam(defaultValue = "16") - private int maximumPoolSize = 16; @UriParam(defaultValue = "true") private boolean usingExecutorService = true; @UriParam(defaultValue = "-1") @@ -420,14 +418,6 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem this.clientInitializerFactory = clientInitializerFactory; } - public int getMaximumPoolSize() { - return maximumPoolSize; - } - - public void setMaximumPoolSize(int maximumPoolSize) { - this.maximumPoolSize = maximumPoolSize; - } - public boolean isUsingExecutorService() { return usingExecutorService; }