activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject activemq git commit: https://issues.apache.org/jira/browse/AMQ-6273
Date Tue, 19 Jul 2016 21:26:53 GMT
Repository: activemq
Updated Branches:
  refs/heads/master 39184e2fb -> e05db7cb5


https://issues.apache.org/jira/browse/AMQ-6273

increment the connect attempt count explicitly to ensure reconnect
policy options are applied. 

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

Branch: refs/heads/master
Commit: e05db7cb5c82660d83e913fa6df77a9e23d0eb8f
Parents: 39184e2
Author: Timothy Bish <tabish121@gmail.com>
Authored: Tue Jul 19 17:26:24 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Tue Jul 19 17:26:24 2016 -0400

----------------------------------------------------------------------
 .../java/org/apache/activemq/network/jms/JmsConnector.java   | 8 ++++++--
 .../org/apache/activemq/network/jms/ReconnectionPolicy.java  | 2 +-
 2 files changed, 7 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/e05db7cb/activemq-broker/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
b/activemq-broker/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
index 73759d1..6cb223a 100755
--- a/activemq-broker/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/jms/JmsConnector.java
@@ -593,7 +593,9 @@ public abstract class JmsConnector implements Service {
         do {
             if (attempt > 0) {
                 try {
-                    Thread.sleep(policy.getNextDelay(attempt));
+                    long nextDelay = policy.getNextDelay(attempt);
+                    LOG.debug("Bridge reconnect attempt {} waiting {}ms before next attempt.",
attempt, nextDelay);
+                    Thread.sleep(nextDelay);
                 } catch(InterruptedException e) {
                 }
             }
@@ -625,9 +627,11 @@ public abstract class JmsConnector implements Service {
                 return;
             } catch(Exception e) {
                 LOG.debug("Failed to establish initial {} connection for JmsConnector [{}]",
new Object[]{ (local ? "local" : "foreign"), attempt }, e);
+            } finally {
+                attempt++;
             }
         }
-        while ((maxRetries == INFINITE || maxRetries > ++attempt) && !connectionService.isShutdown());
+        while ((maxRetries == INFINITE || maxRetries > attempt) && !connectionService.isShutdown());
 
         this.failed.set(true);
     }

http://git-wip-us.apache.org/repos/asf/activemq/blob/e05db7cb/activemq-broker/src/main/java/org/apache/activemq/network/jms/ReconnectionPolicy.java
----------------------------------------------------------------------
diff --git a/activemq-broker/src/main/java/org/apache/activemq/network/jms/ReconnectionPolicy.java
b/activemq-broker/src/main/java/org/apache/activemq/network/jms/ReconnectionPolicy.java
index 061ba2a..c152004 100644
--- a/activemq-broker/src/main/java/org/apache/activemq/network/jms/ReconnectionPolicy.java
+++ b/activemq-broker/src/main/java/org/apache/activemq/network/jms/ReconnectionPolicy.java
@@ -234,7 +234,7 @@ public class ReconnectionPolicy {
         long nextDelay = initialReconnectDelay;
 
         if (useExponentialBackOff) {
-            nextDelay = nextDelay * (long)(attempt * backOffMultiplier);
+            nextDelay = Math.max(initialReconnectDelay, nextDelay * (long)((attempt - 1)
* backOffMultiplier));
         }
 
         if (maximumReconnectDelay > 0 && nextDelay > maximumReconnectDelay)
{


Mime
View raw message