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 2012/12/17 15:53:45 UTC

svn commit: r1422957 - in /camel/trunk/components/camel-netty/src: main/java/org/apache/camel/component/netty/ test/java/org/apache/camel/component/netty/

Author: davsclaus
Date: Mon Dec 17 14:53:44 2012
New Revision: 1422957

URL: http://svn.apache.org/viewvc?rev=1422957&view=rev
Log:
CAMEL-5886: Added option backlog to camel-netty.

Added:
    camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyBacklogTest.java
      - copied, changed from r1422832, camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPSyncTest.java
Modified:
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
    camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java

Modified: camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java?rev=1422957&r1=1422956&r2=1422957&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java (original)
+++ camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java Mon Dec 17 14:53:44 2012
@@ -82,6 +82,7 @@ public class NettyConfiguration implemen
     private int producerPoolMinIdle;
     private int producerPoolMaxIdle = 100;
     private long producerPoolMinEvictableIdle = 5 * 60 * 1000L;
+    private int backlog;
     
     /**
      * Returns a copy of this configuration
@@ -573,6 +574,14 @@ public class NettyConfiguration implemen
         this.producerPoolMinEvictableIdle = producerPoolMinEvictableIdle;
     }
 
+    public int getBacklog() {
+        return backlog;
+    }
+
+    public void setBacklog(int backlog) {
+        this.backlog = backlog;
+    }
+
     private static <T> void addToHandlersList(List<T> configured, List<T> handlers, Class<T> handlerType) {
         if (handlers != null) {
             for (int x = 0; x < handlers.size(); x++) {

Modified: camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java?rev=1422957&r1=1422956&r2=1422957&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java (original)
+++ camel/trunk/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java Mon Dec 17 14:53:44 2012
@@ -182,6 +182,13 @@ public class NettyConsumer extends Defau
         serverBootstrap.setOption("reuseAddress", configuration.isReuseAddress());
         serverBootstrap.setOption("child.reuseAddress", configuration.isReuseAddress());
         serverBootstrap.setOption("child.connectTimeoutMillis", configuration.getConnectTimeout());
+        if (configuration.getBacklog() > 0) {
+            serverBootstrap.setOption("backlog", configuration.getBacklog());
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Created ServerBootstrap {} with options: {}", serverBootstrap, serverBootstrap.getOptions());
+        }
 
         // set the pipeline factory, which creates the pipeline for each newly created channels
         serverBootstrap.setPipelineFactory(pipelineFactory);
@@ -212,6 +219,13 @@ public class NettyConsumer extends Defau
             connectionlessServerBootstrap.setOption("receiveBufferSizePredictorFactory",
                 new FixedReceiveBufferSizePredictorFactory(configuration.getReceiveBufferSizePredictor()));
         }
+        if (configuration.getBacklog() > 0) {
+            serverBootstrap.setOption("backlog", configuration.getBacklog());
+        }
+
+        if (log.isDebugEnabled()) {
+            log.debug("Created ConnectionlessBootstrap {} with options: {}", connectionlessServerBootstrap, connectionlessServerBootstrap.getOptions());
+        }
 
         // set the pipeline factory, which creates the pipeline for each newly created channels
         connectionlessServerBootstrap.setPipelineFactory(pipelineFactory);

Copied: camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyBacklogTest.java (from r1422832, camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPSyncTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyBacklogTest.java?p2=camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyBacklogTest.java&p1=camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPSyncTest.java&r1=1422832&r2=1422957&rev=1422957&view=diff
==============================================================================
--- camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyTCPSyncTest.java (original)
+++ camel/trunk/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyBacklogTest.java Mon Dec 17 14:53:44 2012
@@ -18,50 +18,16 @@ package org.apache.camel.component.netty
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
-import org.apache.camel.Produce;
-import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
-import org.junit.Test;
 
-public class NettyTCPSyncTest extends BaseNettyTest {
-    
-    @Produce(uri = "direct:start")
-    protected ProducerTemplate producerTemplate;
-
-    @Test
-    public void testTCPStringInOutWithNettyConsumer() throws Exception {
-        String response = producerTemplate.requestBody(
-            "netty:tcp://localhost:{{port}}?sync=true",
-            "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);        
-        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
-    }
-
-    @Test
-    public void testTCPStringInOutWithNettyConsumer2Times() throws Exception {
-        String response = producerTemplate.requestBody(
-            "netty:tcp://localhost:{{port}}?sync=true",
-            "Epitaph in Kohima, India marking the WWII Battle of Kohima and Imphal, Burma Campaign - Attributed to John Maxwell Edmonds", String.class);
-        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
-
-        response = producerTemplate.requestBody(
-            "netty:tcp://localhost:{{port}}?sync=true",
-            "Hello World", String.class);
-        assertEquals("When You Go Home, Tell Them Of Us And Say, For Your Tomorrow, We Gave Our Today.", response);
-    }
-
-    @Test
-    public void testTCPObjectInOutWithNettyConsumer() throws Exception {
-        Poetry poetry = new Poetry();
-        Poetry response = (Poetry) producerTemplate.requestBody("netty:tcp://localhost:{{port}}?sync=true", poetry);
-        assertEquals("Dr. Sarojini Naidu", response.getPoet());
-    }
+public class NettyBacklogTest extends NettyTCPSyncTest {
     
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("netty:tcp://localhost:{{port}}?sync=true")
+                from("netty:tcp://localhost:{{port}}?sync=true&backlog=500")
                     .process(new Processor() {
                         public void process(Exchange exchange) throws Exception {
                             if (exchange.getIn().getBody() instanceof Poetry) {