camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1185937 - in /camel/branches/camel-2.8.x: ./ camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/processor/
Date Wed, 19 Oct 2011 01:03:25 GMT
Author: dkulp
Date: Wed Oct 19 01:03:24 2011
New Revision: 1185937

URL: http://svn.apache.org/viewvc?rev=1185937&view=rev
Log:
Merged revisions 1185928 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1185928 | joed | 2011-10-18 20:20:09 -0400 (Tue, 18 Oct 2011) | 6 lines
  
  Dynamic delays via header on a redelivery.
  Full test-suite done in core.
  
  https://issues.apache.org/jira/browse/CAMEL-4558
  
  Thanks Rich!
........

Added:
    camel/branches/camel-2.8.x/camel-core/src/test/java/org/apache/camel/processor/RedeliveryWithExceptionAndFaultDelayInHeader.java
      - copied unchanged from r1185928, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RedeliveryWithExceptionAndFaultDelayInHeader.java
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java

Propchange: camel/branches/camel-2.8.x/
            ('svn:mergeinfo' removed)

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=1185937&r1=1185936&r2=1185937&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/Exchange.java Wed
Oct 19 01:03:24 2011
@@ -159,6 +159,7 @@ public interface Exchange {
     String REDELIVERY_COUNTER      = "CamelRedeliveryCounter";
     String REDELIVERY_MAX_COUNTER  = "CamelRedeliveryMaxCounter";
     String REDELIVERY_EXHAUSTED    = "CamelRedeliveryExhausted";
+    String REDELIVERY_DELAY        = "CamelRedeliveryDelay";
     String ROLLBACK_ONLY           = "CamelRollbackOnly";
     String ROLLBACK_ONLY_LAST      = "CamelRollbackOnlyLast";
     String ROUTE_STOP              = "CamelRouteStop";

Modified: camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=1185937&r1=1185936&r2=1185937&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++ camel/branches/camel-2.8.x/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Wed Oct 19 01:03:24 2011
@@ -265,7 +265,7 @@ public abstract class RedeliveryErrorHan
 
             if (data.redeliveryCounter > 0) {
                 // calculate delay
-                data.redeliveryDelay = data.currentRedeliveryPolicy.calculateRedeliveryDelay(data.redeliveryDelay,
data.redeliveryCounter);
+                data.redeliveryDelay = determineRedeliveryDelay(exchange, data.currentRedeliveryPolicy,
data.redeliveryDelay, data.redeliveryCounter);
 
                 if (data.redeliveryDelay > 0) {
                     // okay there is a delay so create a scheduled task to have it executed
in the future
@@ -355,6 +355,32 @@ public abstract class RedeliveryErrorHan
     }
 
     /**
+     * <p>Determines the redelivery delay time by first inspecting the Message header
{@link Exchange#REDELIVERY_DELAY}
+     * and if not present, defaulting to {@link RedeliveryPolicy#calculateRedeliveryDelay(long,
int)}</p>
+     *
+     * <p>In order to prevent manipulation of the RedeliveryData state, the values
of {@link RedeliveryData#redeliveryDelay}
+     * and {@link RedeliveryData#redeliveryCounter} are copied in.</p>
+     *
+     * @param exchange The current exchange in question.
+     * @param redeliveryPolicy The RedeliveryPolicy to use in the calculation.
+     * @param redeliveryDelay The default redelivery delay from RedeliveryData
+     * @param redeliveryCounter The redeliveryCounter
+     * @return The time to wait before the next redelivery.
+     */
+    protected long determineRedeliveryDelay(Exchange exchange, RedeliveryPolicy redeliveryPolicy,
long redeliveryDelay, int redeliveryCounter){
+        Message message = exchange.getIn();
+        Long delay = message.getHeader(Exchange.REDELIVERY_DELAY, Long.class);
+        if (delay == null) {
+            delay = redeliveryPolicy.calculateRedeliveryDelay(redeliveryDelay, redeliveryCounter);
+        }else{
+            if (log.isDebugEnabled()) {
+                log.debug("Redelivery delay is {} from Message.getHeader(Exchange.REDELIVERY_DELAY)",
new Object[]{delay});
+            }
+        }
+        return delay;
+    }
+
+    /**
      * This logic is only executed if we have to retry redelivery asynchronously, which have
to be done from the callback.
      * <p/>
      * And therefore the logic is a bit different than the synchronous <tt>processErrorHandler</tt>
method which can use



Mime
View raw message