camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r965414 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-jms/src/test/java/org/apache/camel/component/jms/
Date Mon, 19 Jul 2010 10:18:36 GMT
Author: davsclaus
Date: Mon Jul 19 10:18:36 2010
New Revision: 965414

URL: http://svn.apache.org/viewvc?rev=965414&view=rev
Log:
CAMEL-2963: Dead letter channel now forces MEP as InOnly when moving message to the DLQ.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
    camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExceptionTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?rev=965414&r1=965413&r2=965414&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
Mon Jul 19 10:18:36 2010
@@ -17,6 +17,7 @@
 package org.apache.camel.builder;
 
 import org.apache.camel.Endpoint;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.NoSuchEndpointException;
 import org.apache.camel.Predicate;
@@ -70,7 +71,8 @@ public class DeadLetterChannelBuilder ex
 
     public Processor getFailureProcessor() {
         if (failureProcessor == null) {
-            failureProcessor = new SendProcessor(deadLetter);
+            // force MEP to be InOnly so when sending to DLQ we would not expect a reply
if the MEP was InOut
+            failureProcessor = new SendProcessor(deadLetter, ExchangePattern.InOnly);
         }
         return failureProcessor;
     }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java?rev=965414&r1=965413&r2=965414&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelTest.java
Mon Jul 19 10:18:36 2010
@@ -19,6 +19,7 @@ package org.apache.camel.processor;
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
 import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -63,6 +64,33 @@ public class DeadLetterChannelTest exten
         assertNotNull("Should have been a cause property", t);
         assertTrue(t instanceof RuntimeException);
         assertEquals("Failed to process due to attempt: 3 being less than: 5", t.getMessage());
+
+        // must be InOnly
+        Exchange dead = deadEndpoint.getReceivedExchanges().get(0);
+        assertEquals(ExchangePattern.InOnly, dead.getPattern());
+    }
+
+    public void testLotsOfAttemptsFailInOut() throws Exception {
+        failUntilAttempt = 5;
+
+        deadEndpoint.expectedBodiesReceived(body);
+        // no traces of redelivery as the dead letter channel will handle the exception when
moving the DLQ
+        deadEndpoint.message(0).header(Exchange.REDELIVERED).isNull();
+        deadEndpoint.message(0).header(Exchange.REDELIVERY_COUNTER).isNull();
+        successEndpoint.expectedMessageCount(0);
+
+        template.requestBody("direct:start", body);
+
+        assertMockEndpointsSatisfied();
+
+        Throwable t = deadEndpoint.getExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT,
Throwable.class);
+        assertNotNull("Should have been a cause property", t);
+        assertTrue(t instanceof RuntimeException);
+        assertEquals("Failed to process due to attempt: 3 being less than: 5", t.getMessage());
+
+        // must be InOnly
+        Exchange dead = deadEndpoint.getReceivedExchanges().get(0);
+        assertEquals(ExchangePattern.InOnly, dead.getPattern());
     }
 
     @Override

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java?rev=965414&r1=965413&r2=965414&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsDeadLetterChannelInOutTest.java
Mon Jul 19 10:18:36 2010
@@ -34,6 +34,12 @@ import static org.apache.camel.component
  */
 public class JmsDeadLetterChannelInOutTest extends CamelTestSupport {
 
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("activemq-data");
+        super.setUp();
+    }
+
     @Test
     public void testJmsDLCInOut() throws Exception {
         Exchange out = template.send("direct:start", new Processor() {
@@ -66,7 +72,7 @@ public class JmsDeadLetterChannelInOutTe
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                errorHandler(deadLetterChannel("activemq:queue:error?disableReplyTo=true"));
+                errorHandler(deadLetterChannel("activemq:queue:error"));
 
                 from("direct:start").throwException(new IllegalArgumentException("Damn"));
             }

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java?rev=965414&r1=965413&r2=965414&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsProducerDisableReplyToTest.java
Mon Jul 19 10:18:36 2010
@@ -30,6 +30,12 @@ import static org.apache.camel.component
  */
 public class JmsProducerDisableReplyToTest extends CamelTestSupport {
 
+    @Override
+    public void setUp() throws Exception {
+        deleteDirectory("activemq-data");
+        super.setUp();
+    }
+
     @Test
     public void testProducerDisableReplyTo() throws Exception {
         String url = "activemq:queue:foo?disableReplyTo=true";

Modified: camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExceptionTest.java?rev=965414&r1=965413&r2=965414&view=diff
==============================================================================
--- camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExceptionTest.java
(original)
+++ camel/trunk/components/camel-jms/src/test/java/org/apache/camel/component/jms/JmsTransferExceptionTest.java
Mon Jul 19 10:18:36 2010
@@ -24,10 +24,10 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Before;
 import org.junit.Test;
+
 import static org.apache.camel.component.jms.JmsComponent.jmsComponentClientAcknowledge;
 
 /**
@@ -58,10 +58,6 @@ public class JmsTransferExceptionTest ex
 
     @Test
     public void testTransferExeption() throws Exception {
-        // should fail as we thrown an exception
-        MockEndpoint dead = getMockEndpoint("mock:dead");
-        dead.expectedMessageCount(1);
-
         // we send something that causes a remote exception
         // then we expect our producer template to thrown
         // an exception with the remote exception as cause
@@ -73,8 +69,6 @@ public class JmsTransferExceptionTest ex
             assertNotNull("Should contain a remote stacktrace", e.getCause().getStackTrace());
         }
 
-        assertMockEndpointsSatisfied();
-
         // we still try redeliver
         assertEquals(3, counter);
     }
@@ -93,7 +87,7 @@ public class JmsTransferExceptionTest ex
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                errorHandler(deadLetterChannel("mock:dead").maximumRedeliveries(2).redeliveryDelay(0).logStackTrace(false).handled(false));
+                errorHandler(defaultErrorHandler().maximumRedeliveries(2));
 
                 from(getUri())
                         .process(new Processor() {



Mime
View raw message