diff --git a/activemq-core/src/main/java/org/apache/activemq/network/CompositeDemandForwardingBridge.java b/activemq-core/src/main/java/org/apache/activemq/network/CompositeDemandForwardingBridge.java index bf7fa328ad..1d2c563d48 100644 --- a/activemq-core/src/main/java/org/apache/activemq/network/CompositeDemandForwardingBridge.java +++ b/activemq-core/src/main/java/org/apache/activemq/network/CompositeDemandForwardingBridge.java @@ -44,6 +44,7 @@ public class CompositeDemandForwardingBridge extends DemandForwardingBridgeSuppo public CompositeDemandForwardingBridge(Transport localBroker, Transport remoteBroker) { super(localBroker, remoteBroker); remoteBrokerName = remoteBroker.toString(); + remoteBrokerNameKnownLatch.countDown(); } protected void serviceRemoteBrokerInfo(Command command) throws IOException { diff --git a/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridge.java b/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridge.java index ccd35cd65b..95a7eca6aa 100755 --- a/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridge.java +++ b/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridge.java @@ -57,6 +57,7 @@ public class DemandForwardingBridge extends DemandForwardingBridgeSupport { ServiceSupport.dispose(this); } } + remoteBrokerNameKnownLatch.countDown(); } } diff --git a/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java b/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java index 5407abc159..62346abbe0 100644 --- a/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java +++ b/activemq-core/src/main/java/org/apache/activemq/network/DemandForwardingBridgeSupport.java @@ -100,6 +100,7 @@ public abstract class DemandForwardingBridgeSupport implements Bridge { protected final ConcurrentHashMap subscriptionMapByRemoteId = new ConcurrentHashMap(); protected final BrokerId localBrokerPath[] = new BrokerId[] { null }; protected CountDownLatch startedLatch = new CountDownLatch(2); + protected CountDownLatch remoteBrokerNameKnownLatch = new CountDownLatch(1); protected boolean decreaseNetworkConsumerPriority; protected int networkTTL = 1; protected final AtomicBoolean remoteInterupted = new AtomicBoolean(false); @@ -212,6 +213,9 @@ public abstract class DemandForwardingBridgeSupport implements Bridge { protected void startLocalBridge() throws Exception { if(localBridgeStarted.compareAndSet(false,true)){ synchronized( this ) { + + remoteBrokerNameKnownLatch.await(); + localConnectionInfo=new ConnectionInfo(); localConnectionInfo.setConnectionId(new ConnectionId(idGenerator.generateId())); localClientId="NC_"+remoteBrokerName+"_inbound"+name;