camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [09/10] camel git commit: 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.
Date Mon, 19 Jan 2015 08:53:55 GMT
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/1a668e86
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a668e86
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a668e86

Branch: refs/heads/master
Commit: 1a668e867144493423ba80557fb6a1e82a1082a2
Parents: fb120df
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Sun Jan 18 17:27:43 2015 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Sun Jan 18 17:27:43 2015 +0100

----------------------------------------------------------------------
 .../mbean/ManagedErrorHandlerMBean.java         |  9 ++++++
 .../management/mbean/ManagedErrorHandler.java   | 29 ++++++++++++++++++++
 .../camel/processor/RedeliveryErrorHandler.java |  4 +++
 .../ManagedErrorHandlerOptionsTest.java         |  3 ++
 4 files changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/1a668e86/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorHandlerMBean.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorHandlerMBean.java
b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorHandlerMBean.java
index 56ed78d..9ba5c74 100644
--- a/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorHandlerMBean.java
+++ b/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedErrorHandlerMBean.java
@@ -35,6 +35,9 @@ public interface ManagedErrorHandlerMBean {
     @ManagedAttribute(description = "When a message is moved to dead letter channel is it
the original message or recent message")
     boolean isDeadLetterUseOriginalMessage();
 
+    @ManagedAttribute(description = "Does this error handler handle new exceptions which
may occur during error handling")
+    boolean isDeadLetterHandleNewException();
+
     @ManagedAttribute(description = "Does this error handler support transactions")
     boolean isSupportTransactions();
 
@@ -113,6 +116,12 @@ public interface ManagedErrorHandlerMBean {
     @ManagedAttribute(description = "RedeliveryPolicy for logging handled exceptions")
     void setLogHandled(Boolean log);
 
+    @ManagedAttribute(description = "RedeliveryPolicy for logging new exceptions")
+    Boolean getLogNewException();
+
+    @ManagedAttribute(description = "RedeliveryPolicy for logging new exceptions")
+    void setLogNewException(Boolean log);
+
     @ManagedAttribute(description = "RedeliveryPolicy for logging handled and continued exceptions")
     Boolean getLogContinued();
 

http://git-wip-us.apache.org/repos/asf/camel/blob/1a668e86/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedErrorHandler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedErrorHandler.java
b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedErrorHandler.java
index d4fe005..3bf076b 100644
--- a/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedErrorHandler.java
+++ b/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedErrorHandler.java
@@ -21,6 +21,7 @@ import org.apache.camel.LoggingLevel;
 import org.apache.camel.Processor;
 import org.apache.camel.api.management.ManagedResource;
 import org.apache.camel.api.management.mbean.ManagedErrorHandlerMBean;
+import org.apache.camel.builder.DefaultErrorHandlerBuilder;
 import org.apache.camel.processor.ErrorHandlerSupport;
 import org.apache.camel.processor.RedeliveryErrorHandler;
 import org.apache.camel.spi.ManagementStrategy;
@@ -87,6 +88,16 @@ public class ManagedErrorHandler implements ManagedErrorHandlerMBean {
         return redelivery.isUseOriginalMessagePolicy();
     }
 
+    public boolean isDeadLetterHandleNewException() {
+        if (!isSupportRedelivery()) {
+            return false;
+        }
+
+        // must be a dead letter channel
+        RedeliveryErrorHandler redelivery = (RedeliveryErrorHandler) errorHandler;
+        return isDeadLetterChannel() && redelivery.isDeadLetterHandleNewException();
+    }
+
     public boolean isSupportTransactions() {
         if (errorHandler instanceof ErrorHandlerSupport) {
             ErrorHandlerSupport ehs = (ErrorHandlerSupport) errorHandler;
@@ -321,6 +332,24 @@ public class ManagedErrorHandler implements ManagedErrorHandlerMBean
{
         redelivery.getRedeliveryPolicy().setLogHandled(log);
     }
 
+    public Boolean getLogNewException() {
+        if (!isSupportRedelivery()) {
+            return null;
+        }
+
+        RedeliveryErrorHandler redelivery = (RedeliveryErrorHandler) errorHandler;
+        return redelivery.getRedeliveryPolicy().isLogNewException();
+    }
+
+    public void setLogNewException(Boolean log) {
+        if (!isSupportRedelivery()) {
+            throw new IllegalArgumentException("This error handler does not support redelivery");
+        }
+
+        RedeliveryErrorHandler redelivery = (RedeliveryErrorHandler) errorHandler;
+        redelivery.getRedeliveryPolicy().setLogNewException(log);
+    }
+
     public Boolean getLogContinued() {
         if (!isSupportRedelivery()) {
             return null;

http://git-wip-us.apache.org/repos/asf/camel/blob/1a668e86/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
index 9fcfc0f..98757e9 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
@@ -672,6 +672,10 @@ public abstract class RedeliveryErrorHandler extends ErrorHandlerSupport
impleme
         return useOriginalMessagePolicy;
     }
 
+    public boolean isDeadLetterHandleNewException() {
+        return deadLetterHandleNewException;
+    }
+
     public RedeliveryPolicy getRedeliveryPolicy() {
         return redeliveryPolicy;
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/1a668e86/camel-core/src/test/java/org/apache/camel/management/ManagedErrorHandlerOptionsTest.java
----------------------------------------------------------------------
diff --git a/camel-core/src/test/java/org/apache/camel/management/ManagedErrorHandlerOptionsTest.java
b/camel-core/src/test/java/org/apache/camel/management/ManagedErrorHandlerOptionsTest.java
index 8182f51..f479095 100644
--- a/camel-core/src/test/java/org/apache/camel/management/ManagedErrorHandlerOptionsTest.java
+++ b/camel-core/src/test/java/org/apache/camel/management/ManagedErrorHandlerOptionsTest.java
@@ -100,6 +100,9 @@ public class ManagedErrorHandlerOptionsTest extends ManagementTestSupport
{
         Boolean uebf = (Boolean) mbeanServer.getAttribute(on, "UseExponentialBackOff");
         assertEquals(true, uebf.booleanValue());
 
+        Boolean ne = (Boolean) mbeanServer.getAttribute(on, "DeadLetterHandleNewException");
+        assertEquals(false, ne.booleanValue());
+
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedMessageCount(1);
 


Mime
View raw message