Updated Branches:
  refs/heads/camel-2.11.x 2fd7c90cc -> 3e23e7f58
  refs/heads/camel-2.12.x 281f3e893 -> c47953b01
  refs/heads/master f7787731e -> 99f7a66ba


CAMEL-6730: Fixed requestTimeout on camel-netty.


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

Branch: refs/heads/master
Commit: 99f7a66ba3dbc0dc9dc32b089cae05e73a3d4bd5
Parents: f778773
Author: Claus Ibsen <[email protected]>
Authored: Wed Sep 11 16:36:19 2013 +0200
Committer: Claus Ibsen <[email protected]>
Committed: Wed Sep 11 16:36:19 2013 +0200

----------------------------------------------------------------------
 .../netty/handlers/ClientChannelHandler.java    |  9 ++++
 .../netty/NettyRequestTimeoutIssueTest.java     | 50 ++++++++++++++++++++
 2 files changed, 59 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/99f7a66b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
index a79c5bb..b55f4b7 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/handlers/ClientChannelHandler.java
@@ -120,6 +120,15 @@ public class ClientChannelHandler extends 
SimpleChannelUpstreamHandler {
 
     @Override
     public void messageReceived(ChannelHandlerContext ctx, MessageEvent 
messageEvent) throws Exception {
+        if (LOG.isTraceEnabled()) {
+            LOG.trace("Message received: {}", messageEvent);
+        }
+
+        if (producer.getConfiguration().getRequestTimeout() > 0) {
+            LOG.trace("Removing timeout channel as we received message");
+            ctx.getPipeline().remove("timeout");
+        }
+
         messageReceived = true;
 
         Exchange exchange = getExchange(ctx);

http://git-wip-us.apache.org/repos/asf/camel/blob/99f7a66b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutIssueTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutIssueTest.java
 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutIssueTest.java
new file mode 100644
index 0000000..9b16148
--- /dev/null
+++ 
b/components/camel-netty/src/test/java/org/apache/camel/component/netty/NettyRequestTimeoutIssueTest.java
@@ -0,0 +1,50 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.netty;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("This test can be run manually")
+public class NettyRequestTimeoutIssueTest extends CamelTestSupport {
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:out")
+                        .to("netty:tcp://localhost:8080?requestTimeout=5000");
+
+                from("netty:tcp://localhost:8080")
+                        .to("log:nettyCase?showAll=true&multiline=true");
+            }
+        };
+    }
+
+    @Test
+    public void test() throws Exception {
+        String result = template.requestBody("direct:out", "hello", 
String.class);
+        Assert.assertEquals("hello", result);
+
+        log.info("Sleeping for 20 seconds, and no Netty exception should 
occur");
+        Thread.sleep(20000);
+    }
+}

Reply via email to