From fb120dfab276f6719ccc64c9741ccb064514ed25 Mon Sep 17 00:00:00 2001 From: Claus Ibsen Date: Sun, 18 Jan 2015 17:18:27 +0100 Subject: [PATCH] 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. --- ...etterChannelNotHandleNewExceptionTest.java | 2 +- .../spring/spi/TransactionErrorHandler.java | 2 +- ...ringDeadLetterChannelNewExceptionTest.java | 29 +++++++++++++ ...etterChannelNotHandleNewExceptionTest.java | 29 +++++++++++++ .../DeadLetterChannelNewExceptionTest.xml | 43 +++++++++++++++++++ ...LetterChannelNotHandleNewExceptionTest.xml | 43 +++++++++++++++++++ 6 files changed, 146 insertions(+), 2 deletions(-) create mode 100644 components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNewExceptionTest.java create mode 100644 components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringDeadLetterChannelNotHandleNewExceptionTest.java create mode 100644 components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml create mode 100644 components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml 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 df4ed94cd4662..1cbf20d804a55 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 void onException(Exchange exchange, Exception exception) throws Exception } } - public void testDeadLetterChannelNewException() throws Exception { + public void testDeadLetterChannelNotHandleNewException() throws Exception { try { template.sendBody("direct:start", "Hello World"); fail("Should have thrown exception"); 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 fba08afcda98c..a27a73f854d36 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 TransactionErrorHandler(CamelContext camelContext, Processor output, Came 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; 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 0000000000000..0c6955429dab7 --- /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"); + } +} 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 0000000000000..7293edffaeadd --- /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"); + } +} 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 0000000000000..91ebbd6a86435 --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNewExceptionTest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + 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 0000000000000..0c3f6b27c1940 --- /dev/null +++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/DeadLetterChannelNotHandleNewExceptionTest.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + +