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-5819
Date Fri, 15 Apr 2016 16:51:03 GMT
Repository: activemq
Updated Branches:
  refs/heads/activemq-5.13.x 32913408a -> 2f935a260


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

Only apply the initialReconnectDelay on the first reconnection attempt
after a connected transport has failed.
(cherry picked from commit c8af70f0949e38270b313b7b8ce305c5870362da)


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

Branch: refs/heads/activemq-5.13.x
Commit: 2f935a260b00577eea64d8c50fa1437b6874e5b9
Parents: 3291340
Author: Timothy Bish <tabish121@gmail.com>
Authored: Fri Apr 15 12:49:49 2016 -0400
Committer: Timothy Bish <tabish121@gmail.com>
Committed: Fri Apr 15 12:50:57 2016 -0400

----------------------------------------------------------------------
 .../transport/failover/FailoverTransport.java   | 26 ++++++++------------
 1 file changed, 10 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq/blob/2f935a26/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
----------------------------------------------------------------------
diff --git a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
index dcb0867..a005732 100755
--- a/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
+++ b/activemq-client/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java
@@ -1002,19 +1002,15 @@ public class FailoverTransport implements CompositeTransport {
                         }
                     }
 
-                    // Sleep for the reconnectDelay if there's no backup and we aren't trying
-                    // for the first time, or we were disposed for some reason.
-                    if (transport == null && !firstConnection && (reconnectDelay
> 0) && !disposed) {
-                        synchronized (sleepMutex) {
-                            if (LOG.isDebugEnabled()) {
-                                LOG.debug("Waiting " + reconnectDelay + " ms before attempting
connection. ");
-                            }
-                            try {
-                                sleepMutex.wait(reconnectDelay);
-                            } catch (InterruptedException e) {
-                                Thread.currentThread().interrupt();
-                            }
-                        }
+                    // When there was no backup and we are reconnecting for the first time
+                    // we honor the initialReconnectDelay before trying a new connection,
after
+                    // this normal reconnect delay happens following a failed attempt.
+                    if (transport == null && !firstConnection && connectFailures
== 0 && initialReconnectDelay > 0 && !disposed) {
+                        // reconnectDelay will be equal to initialReconnectDelay since we
are on
+                        // the first connect attempt after we had a working connection, doDelay
+                        // will apply updates to move to the next reconnectDelay value based
on
+                        // configuration.
+                        doDelay();
                     }
 
                     Iterator<URI> iter = connectList.iterator();
@@ -1140,9 +1136,7 @@ public class FailoverTransport implements CompositeTransport {
     private void doDelay() {
         if (reconnectDelay > 0) {
             synchronized (sleepMutex) {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("Waiting " + reconnectDelay + " ms before attempting connection");
-                }
+                LOG.debug("Waiting {} ms before attempting connection", reconnectDelay);
                 try {
                     sleepMutex.wait(reconnectDelay);
                 } catch (InterruptedException e) {


Mime
View raw message