camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r905291 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: builder/DefaultErrorHandlerBuilder.java processor/RedeliveryErrorHandler.java processor/RedeliveryPolicy.java
Date Mon, 01 Feb 2010 14:44:08 GMT
Author: davsclaus
Date: Mon Feb  1 14:44:07 2010
New Revision: 905291

URL: http://svn.apache.org/viewvc?rev=905291&view=rev
Log:
CAMEL-2435: Error handler will now by default log stacktrace for exhausted exchanges which
can help see the problem in case caller will swallow the exception etc.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=905291&r1=905290&r2=905291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
Mon Feb  1 14:44:07 2010
@@ -126,6 +126,11 @@
         return this;
     }
 
+    public DefaultErrorHandlerBuilder logRetryStackTrace(boolean logRetryStackTrace) {
+        getRedeliveryPolicy().setLogRetryStackTrace(logRetryStackTrace);
+        return this;
+    }
+
     /**
      * Sets whether the exchange should be marked as handled or not.
      *

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=905291&r1=905290&r2=905291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Mon Feb  1 14:44:07 2010
@@ -391,11 +391,18 @@
         }
 
         LoggingLevel newLogLevel;
+        boolean logStrackTrace;
         if (shouldRedeliver) {
             newLogLevel = data.currentRedeliveryPolicy.getRetryAttemptedLogLevel();
+            logStrackTrace = data.currentRedeliveryPolicy.isLogRetryStackTrace();
         } else {
             newLogLevel = data.currentRedeliveryPolicy.getRetriesExhaustedLogLevel();
+            logStrackTrace = data.currentRedeliveryPolicy.isLogStackTrace();
         }
+        if (e == null) {
+            e = exchange.getProperty(Exchange.EXCEPTION_CAUGHT, Exception.class);
+        }
+
         if (exchange.isRollbackOnly()) {
             String msg = "Rollback exchange";
             if (exchange.getException() != null) {
@@ -408,7 +415,7 @@
                 // otherwise use the desired logging level
                 logger.log(msg, newLogLevel);
             }
-        } else if (data.currentRedeliveryPolicy.isLogStackTrace() && e != null) {
+        } else if (e != null && logStrackTrace) {
             logger.log(message, e, newLogLevel);
         } else {
             logger.log(message, newLogLevel);

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java?rev=905291&r1=905290&r2=905291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
Mon Feb  1 14:44:07 2010
@@ -45,7 +45,8 @@
  *   <li>useCollisionAvoidance = false</li>
  *   <li>retriesExhaustedLogLevel = LoggingLevel.ERROR</li>
  *   <li>retryAttemptedLogLevel = LoggingLevel.DEBUG</li>
- *   <li>logStrackTrace = false</li>
+ *   <li>logRetryStackTrace = false</li>
+ *   <li>logStackTrace = true</li>
  * </ul>
  * <p/>
  * Setting the maximumRedeliveries to a negative value such as -1 will then always redeliver
(unlimited).
@@ -85,7 +86,8 @@
     protected boolean useCollisionAvoidance;
     protected LoggingLevel retriesExhaustedLogLevel = LoggingLevel.ERROR;
     protected LoggingLevel retryAttemptedLogLevel = LoggingLevel.DEBUG;
-    protected boolean logStackTrace;
+    protected boolean logStackTrace = true;
+    protected boolean logRetryStackTrace;
     protected String delayPattern;
 
     public RedeliveryPolicy() {
@@ -98,7 +100,8 @@
             + ", maximumRedeliveryDelay=" + maximumRedeliveryDelay
             + ", retriesExhaustedLogLevel=" + retriesExhaustedLogLevel
             + ", retryAttemptedLogLevel=" + retryAttemptedLogLevel
-            + ", logTraceStace=" + logStackTrace
+            + ", logStackTrace=" + logStackTrace
+            + ", logRetryStackTrace=" + logRetryStackTrace
             + ", useExponentialBackOff="  + useExponentialBackOff
             + ", backOffMultiplier=" + backOffMultiplier
             + ", useCollisionAvoidance=" + useCollisionAvoidance
@@ -296,7 +299,7 @@
     }    
     
     /**
-     * Sets the logging level to use for log messages when retries are attempted.
+     * Sets whether to log stacktraces for failed messages.
      */
     public RedeliveryPolicy logStackTrace(boolean logStackTrace) {
         setLogStackTrace(logStackTrace);
@@ -304,6 +307,14 @@
     }
 
     /**
+     * Sets whether to log stacktrace for failed redelivery attempts
+     */
+    public RedeliveryPolicy logRetryStackTrace(boolean logRetryStackTrace) {
+        setLogRetryStackTrace(logRetryStackTrace);
+        return this;
+    }
+
+    /**
      * Sets the delay pattern with delay intervals.
      */
     public RedeliveryPolicy delayPattern(String delayPattern) {
@@ -471,4 +482,16 @@
     public void setLogStackTrace(boolean logStackTrace) {
         this.logStackTrace = logStackTrace;
     }
+
+    public boolean isLogRetryStackTrace() {
+        return logRetryStackTrace;
+    }
+
+    /**
+     * Sets whether stack traces should be logged or not
+     */
+    public void setLogRetryStackTrace(boolean logRetryStackTrace) {
+        this.logRetryStackTrace = logRetryStackTrace;
+    }
+
 }



Mime
View raw message