CAMEL-7050: DeadLetterChannel should make more clear that it handles any new 
exception also. Added option to configure this behavior so ppl can turn that 
off and let new exceptions be unhandled, so transactions can rollback.


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

Branch: refs/heads/master
Commit: fb120dfab276f6719ccc64c9741ccb064514ed25
Parents: 37d4914
Author: Claus Ibsen <[email protected]>
Authored: Sun Jan 18 17:18:27 2015 +0100
Committer: Claus Ibsen <[email protected]>
Committed: Sun Jan 18 17:18:27 2015 +0100

----------------------------------------------------------------------
 ...dLetterChannelNotHandleNewExceptionTest.java |  2 +-
 .../spring/spi/TransactionErrorHandler.java     |  2 +-
 ...SpringDeadLetterChannelNewExceptionTest.java | 29 +++++++++++++
 ...dLetterChannelNotHandleNewExceptionTest.java | 29 +++++++++++++
 .../DeadLetterChannelNewExceptionTest.xml       | 43 ++++++++++++++++++++
 ...adLetterChannelNotHandleNewExceptionTest.xml | 43 ++++++++++++++++++++
 6 files changed, 146 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelNotHandleNewExceptionTest.java
----------------------------------------------------------------------
diff --git 
a/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelNotHandleNewExceptionTest.java
 
b/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelNotHandleNewExceptionTest.java
index df4ed94..1cbf20d 100644
--- 
a/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelNotHandleNewExceptionTest.java
+++ 
b/camel-core/src/test/java/org/apache/camel/processor/DeadLetterChannelNotHandleNewExceptionTest.java
@@ -31,7 +31,7 @@ public class DeadLetterChannelNotHandleNewExceptionTest 
extends ContextTestSuppo
         }
     }
 
-    public void testDeadLetterChannelNewException() throws Exception {
+    public void testDeadLetterChannelNotHandleNewException() throws Exception {
         try {
             template.sendBody("direct:start", "Hello World");
             fail("Should have thrown exception");

http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
 
b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
index fba08af..a27a73f 100644
--- 
a/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
+++ 
b/components/camel-spring/src/main/java/org/apache/camel/spring/spi/TransactionErrorHandler.java
@@ -67,7 +67,7 @@ public class TransactionErrorHandler extends 
RedeliveryErrorHandler {
             TransactionTemplate transactionTemplate, Predicate retryWhile, 
ScheduledExecutorService executorService,
             LoggingLevel rollbackLoggingLevel) {
 
-        super(camelContext, output, logger, redeliveryProcessor, 
redeliveryPolicy, null, null, false, retryWhile, executorService);
+        super(camelContext, output, logger, redeliveryProcessor, 
redeliveryPolicy, null, null, false, false, retryWhile, executorService);
         setExceptionPolicy(exceptionPolicyStrategy);
         this.transactionTemplate = transactionTemplate;
         this.rollbackLoggingLevel = rollbackLoggingLevel;

http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNewExceptionTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNewExceptionTest.java
 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNewExceptionTest.java
new file mode 100644
index 0000000..0c69554
--- /dev/null
+++ 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNewExceptionTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.DeadLetterChannelNewExceptionTest;
+
+import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringDeadLetterChannelNewExceptionTest extends 
DeadLetterChannelNewExceptionTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandleNewExceptionTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandleNewExceptionTest.java
 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandleNewExceptionTest.java
new file mode 100644
index 0000000..7293edf
--- /dev/null
+++ 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandleNewExceptionTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.DeadLetterChannelNotHandleNewExceptionTest;
+
+import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringDeadLetterChannelNotHandleNewExceptionTest extends 
DeadLetterChannelNotHandleNewExceptionTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml");
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml
new file mode 100644
index 0000000..91ebbd6
--- /dev/null
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <bean id="forced" class="java.lang.IllegalArgumentException">
+    <constructor-arg index="0" value="Forced"/>
+  </bean>
+
+  <bean id="badErrorHandler"
+        
class="org.apache.camel.processor.DeadLetterChannelNotHandleNewExceptionTest.BadErrorHandler"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring"; 
errorHandlerRef="dlc">
+
+    <errorHandler id="dlc" type="DeadLetterChannel" 
deadLetterUri="bean:badErrorHandler" deadLetterHandleNewException="true"/>
+
+    <route>
+      <from uri="direct:start"/>
+      <log message="Incoming ${body}"/>
+      <throwException ref="forced"/>
+    </route>
+  </camelContext>
+
+</beans>

http://git-wip-us.apache.org/repos/asf/camel/blob/fb120dfa/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml
----------------------------------------------------------------------
diff --git 
a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml
 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml
new file mode 100644
index 0000000..0c3f6b2
--- /dev/null
+++ 
b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+  <bean id="forced" class="java.lang.IllegalArgumentException">
+    <constructor-arg index="0" value="Forced"/>
+  </bean>
+
+  <bean id="badErrorHandler"
+        
class="org.apache.camel.processor.DeadLetterChannelNotHandleNewExceptionTest.BadErrorHandler"/>
+
+  <camelContext xmlns="http://camel.apache.org/schema/spring"; 
errorHandlerRef="dlc">
+
+    <errorHandler id="dlc" type="DeadLetterChannel" 
deadLetterUri="bean:badErrorHandler" deadLetterHandleNewException="false"/>
+
+    <route>
+      <from uri="direct:start"/>
+      <log message="Incoming ${body}"/>
+      <throwException ref="forced"/>
+    </route>
+  </camelContext>
+
+</beans>

Reply via email to