You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/10/24 14:35:16 UTC

[2/2] git commit: CAMEL-6894: camel-netty-http - Should use orderedThreadPoolExecutor

CAMEL-6894: camel-netty-http - Should use orderedThreadPoolExecutor


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/958fd907
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/958fd907
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/958fd907

Branch: refs/heads/camel-2.12.x
Commit: 958fd9079e38f5020c532473aaad63d0e7e5633b
Parents: 4e6bab3
Author: Claus Ibsen <da...@apache.org>
Authored: Thu Oct 24 14:33:31 2013 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Thu Oct 24 14:34:16 2013 +0200

----------------------------------------------------------------------
 .../component/netty/http/HttpServerPipelineFactory.java  | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/958fd907/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 8865fd3..2ae1794 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -32,6 +32,7 @@ import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
 import org.jboss.netty.handler.codec.http.HttpContentCompressor;
 import org.jboss.netty.handler.codec.http.HttpRequestDecoder;
 import org.jboss.netty.handler.codec.http.HttpResponseEncoder;
+import org.jboss.netty.handler.execution.ExecutionHandler;
 import org.jboss.netty.handler.ssl.SslHandler;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -90,6 +91,16 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory {
             pipeline.addLast("deflater", new HttpContentCompressor());
         }
 
+        if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
+            // this must be added just before the HttpServerMultiplexChannelHandler
+            // use ordered thread pool, to ensure we process the events in order, and can send back
+            // replies in the expected order. eg this is required by TCP.
+            // and use a Camel thread factory so we have consistent thread namings
+            ExecutionHandler executionHandler = new ExecutionHandler(consumer.getEndpoint().getComponent().getExecutorService());
+            pipeline.addLast("executionHandler", executionHandler);
+            LOG.debug("Using OrderedMemoryAwareThreadPoolExecutor with core pool size: {}", consumer.getConfiguration().getMaximumPoolSize());
+        }
+
         int port = consumer.getConfiguration().getPort();
         ChannelHandler handler = consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
         pipeline.addLast("handler", handler);