You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2022/01/15 05:59:38 UTC

[activemq] branch activemq-5.16.x updated: [AMQ-8443] Allow reconnect command to work

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.16.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.16.x by this push:
     new d915c79  [AMQ-8443] Allow reconnect command to work
d915c79 is described below

commit d915c791aa491112259b4385ae856b441f3745b0
Author: Matt Pavlovich <ma...@hyte.io>
AuthorDate: Thu Dec 23 07:57:24 2021 -0600

    [AMQ-8443] Allow reconnect command to work
    
    (cherry picked from commit bc9ff5a09fb0aad28d94c2aa72b4e31011b61905)
---
 .../org/apache/activemq/transport/failover/FailoverTransport.java  | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

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 6b6f518..dcb4cb8 100644
--- 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
@@ -122,6 +122,7 @@ public class FailoverTransport implements CompositeTransport {
     private String updateURIsURL = null;
     private boolean rebalanceUpdateURIs = true;
     private boolean doRebalance = false;
+    private boolean doReconnect = false;
     private boolean connectedToPriority = false;
 
     private boolean priorityBackup = false;
@@ -750,6 +751,7 @@ public class FailoverTransport implements CompositeTransport {
             reconnect(rebalance);
         }
     }
+    
 
     @Override
     public void remove(boolean rebalance, URI u[]) {
@@ -943,7 +945,7 @@ public class FailoverTransport implements CompositeTransport {
                     failure = new IOException("No uris available to connect to.");
                 } else {
                     if (doRebalance) {
-                        if (connectedToPriority || compareURIs(connectList.get(0), connectedTransportURI)) {
+                        if (connectedToPriority || (!doReconnect && compareURIs(connectList.get(0), connectedTransportURI))) {
                             // already connected to first in the list, no need to rebalance
                             doRebalance = false;
                             return false;
@@ -958,6 +960,7 @@ public class FailoverTransport implements CompositeTransport {
                             } catch (Exception e) {
                                 LOG.debug("Caught an exception stopping existing transport for rebalance", e);
                             }
+                            doReconnect = false;
                         }
                         doRebalance = false;
                     }
@@ -1256,6 +1259,8 @@ public class FailoverTransport implements CompositeTransport {
 
     @Override
     public void reconnect(URI uri) throws IOException {
+        uris.clear();
+        doReconnect = true;
         add(true, new URI[]{uri});
     }