camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1229849 - in /camel/branches/camel-2.7.x/camel-core/src: main/java/org/apache/camel/component/seda/ test/java/org/apache/camel/component/seda/
Date Wed, 11 Jan 2012 01:23:25 GMT
Author: hadrian
Date: Wed Jan 11 01:23:25 2012
New Revision: 1229849

URL: http://svn.apache.org/viewvc?rev=1229849&view=rev
Log:
CAMEL-4882. Remove timed out Exchanges from seda queue

Modified:
    camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutDisabledTest.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java

Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java?rev=1229849&r1=1229848&r2=1229849&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
(original)
+++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/component/seda/SedaProducer.java
Wed Jan 11 01:23:25 2012
@@ -117,6 +117,8 @@ public class SedaProducer extends Collec
                     exchange.setException(new ExchangeTimedOutException(exchange, timeout));
                     // count down to indicate timeout
                     latch.countDown();
+                    // remove   timed out Exchange from queue
+                    queue.remove(copy);
                 }
             } else {
                 if (log.isTraceEnabled()) {

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutDisabledTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutDisabledTest.java?rev=1229849&r1=1229848&r2=1229849&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutDisabledTest.java
(original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutDisabledTest.java
Wed Jan 11 01:23:25 2012
@@ -27,10 +27,10 @@ import org.apache.camel.builder.RouteBui
  */
 public class SedaTimeoutDisabledTest extends ContextTestSupport {
 
-    public void testSedaNoTineout() throws Exception {
+    public void testSedaNoTimeout() throws Exception {
         Future<String> out = template.asyncRequestBody("seda:foo?timeout=0", "World",
String.class);
-        // use 60 sec failsafe in case something hangs
-        assertEquals("Bye World", out.get(60, TimeUnit.SECONDS));
+        // use 5 sec failsafe in case something hangs
+        assertEquals("Bye World", out.get(5, TimeUnit.SECONDS));
     }
 
     @Override
@@ -38,7 +38,7 @@ public class SedaTimeoutDisabledTest ext
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:foo").to("mock:before").delay(2000).transform(body().prepend("Bye
")).to("mock:result");
+                from("seda:foo").to("mock:before").delay(500).transform(body().prepend("Bye
")).to("mock:result");
             }
         };
     }

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java?rev=1229849&r1=1229848&r2=1229849&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
(original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/component/seda/SedaTimeoutTest.java
Wed Jan 11 01:23:25 2012
@@ -28,29 +28,44 @@ import org.apache.camel.builder.RouteBui
  * @version 
  */
 public class SedaTimeoutTest extends ContextTestSupport {
+    private int timeout = 100;
 
-    public void testSedaNoTineout() throws Exception {
+    public void testSedaNoTimeout() throws Exception {
         Future<String> out = template.asyncRequestBody("seda:foo", "World", String.class);
         assertEquals("Bye World", out.get());
     }
 
-    public void testSedaTineout() throws Exception {
-        Future<String> out = template.asyncRequestBody("seda:foo?timeout=100", "World",
String.class);
+    public void testSedaTimeout() throws Exception {
+        Future<String> out = template.asyncRequestBody("seda:foo?timeout=" + timeout,
"World", String.class);
         try {
             out.get();
             fail("Should have thrown an exception");
         } catch (ExecutionException e) {
             assertIsInstanceOf(CamelExecutionException.class, e.getCause());
             assertIsInstanceOf(ExchangeTimedOutException.class, e.getCause().getCause());
+
+            SedaEndpoint se = (SedaEndpoint)context.getRoute("seda").getEndpoint();
+            assertNotNull("Consumer endpoint cannot be null", se);
+            assertEquals("Timeout Exchanges should be removed from queue", 0, se.getCurrentQueueSize());
         }
     }
 
+    public void testSedaTimeoutWithStoppedRoute() throws Exception {
+        context.stopRoute("seda");
+        timeout = 500;
+        testSedaTimeout();
+    }
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:foo").to("mock:before").delay(250).transform(body().prepend("Bye
")).to("mock:result");
+                from("seda:foo").routeId("seda")
+                    .to("mock:before")
+                    .delay(250)
+                    .transform(body().prepend("Bye "))
+                    .to("mock:result");
             }
         };
     }



Mime
View raw message