activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [06/10] activemq git commit: https://issues.apache.org/jira/browse/AMQ-5674 - revisit change - use single redelivey delay attribute for both initial and subsequent delays - resolves regression in BrokerRedeliveryTest
Date Tue, 04 Aug 2015 15:59:25 GMT
https://issues.apache.org/jira/browse/AMQ-5674  - revisit change - use single redelivey delay
attribute for both initial and subsequent delays - resolves regression in BrokerRedeliveryTest


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

Branch: refs/heads/activemq-5.11.x
Commit: 6c384c9b79aeb16c48ce98bb04cd99b2939e64d0
Parents: f1f171d
Author: gtully <gary.tully@gmail.com>
Authored: Fri Apr 3 14:18:55 2015 +0100
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Aug 4 08:50:03 2015 -0400

----------------------------------------------------------------------
 .../apache/activemq/broker/util/RedeliveryPlugin.java | 14 ++++----------
 .../java/org/apache/activemq/RedeliveryPolicy.java    |  5 +----
 .../apache/activemq/ra/ActiveMQActivationSpec.java    |  1 +
 .../org/apache/activemq/RedeliveryPolicyTest.java     |  6 +++---
 .../apache/activemq/broker/BrokerRedeliveryTest.java  |  2 +-
 5 files changed, 10 insertions(+), 18 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/6c384c9b/activemq-broker/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java
b/activemq-broker/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java
index 5a90753..f270744 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/broker/util/RedeliveryPlugin.java
@@ -140,9 +140,10 @@ public class RedeliveryPlugin extends BrokerPluginSupport {
                     int redeliveryCount = messageReference.getRedeliveryCounter();
                     if (RedeliveryPolicy.NO_MAXIMUM_REDELIVERIES == maximumRedeliveries ||
redeliveryCount < maximumRedeliveries) {
 
-                        long delay = ( redeliveryCount == 0 ?
-                                redeliveryPolicy.getInitialRedeliveryDelay() :
-                                redeliveryPolicy.getNextRedeliveryDelay(getExistingDelay(messageReference)));
+                        long delay = redeliveryPolicy.getInitialRedeliveryDelay();
+                        for (int i = 0; i < redeliveryCount; i++) {
+                            delay = redeliveryPolicy.getNextRedeliveryDelay(delay);
+                        }
 
                         scheduleRedelivery(context, messageReference, delay, ++redeliveryCount);
                     } else if (isSendToDlqIfMaxRetriesExceeded()) {
@@ -199,11 +200,4 @@ public class RedeliveryPlugin extends BrokerPluginSupport {
         }
     }
 
-    private int getExistingDelay(MessageReference messageReference) throws IOException {
-        Object val = messageReference.getMessage().getProperty(REDELIVERY_DELAY);
-        if (val instanceof Long) {
-            return ((Long)val).intValue();
-        }
-        return 0;
-    }
 }

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c384c9b/activemq-client/src/main/java/org/apache/activemq/RedeliveryPolicy.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/RedeliveryPolicy.java b/activemq-client/src/main/java/org/apache/activemq/RedeliveryPolicy.java
index e0a8f33..91f2b71 100644
--- a/activemq-client/src/main/java/org/apache/activemq/RedeliveryPolicy.java
+++ b/activemq-client/src/main/java/org/apache/activemq/RedeliveryPolicy.java
@@ -98,10 +98,7 @@ public class RedeliveryPolicy extends DestinationMapEntry implements Cloneable,
     }
 
     public long getNextRedeliveryDelay(long previousDelay) {
-        long nextDelay = initialRedeliveryDelay;
-        if (nextDelay == 0) {
-            nextDelay = redeliveryDelay;
-        }
+        long nextDelay = redeliveryDelay;
 
         if (previousDelay > 0 && useExponentialBackOff && backOffMultiplier
> 1) {
             nextDelay = (long) (previousDelay * backOffMultiplier);

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c384c9b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
----------------------------------------------------------------------
diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
index c17f7f0..0c1440b 100644
--- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
+++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQActivationSpec.java
@@ -639,6 +639,7 @@ public class ActiveMQActivationSpec implements MessageActivationSpec,
Serializab
      */
     public void setInitialRedeliveryDelay(long initialRedeliveryDelay) {
         lazyCreateRedeliveryPolicy().setInitialRedeliveryDelay(initialRedeliveryDelay);
+        redeliveryPolicy.setRedeliveryDelay(initialRedeliveryDelay);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c384c9b/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java
index 1f8f687..b7a870a 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/RedeliveryPolicyTest.java
@@ -75,11 +75,11 @@ public class RedeliveryPolicyTest extends JmsTestSupport {
         policy.setInitialRedeliveryDelay(500);
 
         long delay = policy.getNextRedeliveryDelay(500);
-        assertEquals(500, delay);
+        assertEquals(1000, delay);
         delay = policy.getNextRedeliveryDelay(delay);
-        assertEquals(500, delay);
+        assertEquals(1000, delay);
         delay = policy.getNextRedeliveryDelay(delay);
-        assertEquals(500, delay);
+        assertEquals(1000, delay);
 
     }
 

http://git-wip-us.apache.org/repos/asf/activemq/blob/6c384c9b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java
----------------------------------------------------------------------
diff --git a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java
b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java
index 1fc7a6a..4320ade 100644
--- a/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java
+++ b/activemq-unit-tests/src/test/java/org/apache/activemq/broker/BrokerRedeliveryTest.java
@@ -81,7 +81,7 @@ public class BrokerRedeliveryTest extends org.apache.activemq.TestSupport
{
             LOG.info("got: " + brokerRedeliveryMessage);
             assertNotNull("got message via broker redelivery after delay", brokerRedeliveryMessage);
             assertEquals("message matches", message.getStringProperty("data"), brokerRedeliveryMessage.getStringProperty("data"));
-            assertEquals("has expiryDelay specified", i == 0 ? initialRedeliveryDelayMillis
: redeliveryDelayMillis, brokerRedeliveryMessage.getLongProperty(RedeliveryPlugin.REDELIVERY_DELAY));
+            assertEquals("has expiryDelay specified - iteration:" + i, i == 0 ? initialRedeliveryDelayMillis
: redeliveryDelayMillis, brokerRedeliveryMessage.getLongProperty(RedeliveryPlugin.REDELIVERY_DELAY));
 
             consumerSession.rollback();
         }


Mime
View raw message