Repository: activemq
Updated Branches:
  refs/heads/master 1ffac14f6 -> c8af70f09


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

Only apply the initialReconnectDelay on the first reconnection attempt
after a connected transport has failed.  

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

Branch: refs/heads/master
Commit: c8af70f0949e38270b313b7b8ce305c5870362da
Parents: 1ffac14
Author: Timothy Bish <[email protected]>
Authored: Fri Apr 15 12:49:49 2016 -0400
Committer: Timothy Bish <[email protected]>
Committed: Fri Apr 15 12:49:49 2016 -0400

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


http://git-wip-us.apache.org/repos/asf/activemq/blob/c8af70f0/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 134b325..553036b 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
@@ -999,19 +999,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();
@@ -1137,9 +1133,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) {

Reply via email to