From f7fa2bc58da06a71d314490f462e17de96e6e14d Mon Sep 17 00:00:00 2001 From: Robert Davies Date: Thu, 5 Jun 2008 17:57:55 +0000 Subject: [PATCH] Fix for https://issues.apache.org/activemq/browse/AMQ-1771 git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@663680 13f79535-47bb-0310-9956-ffa450edef68 --- .../transport/failover/FailoverTransport.java | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java index d6d38e19a1..0883e6b123 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/failover/FailoverTransport.java @@ -69,6 +69,7 @@ public class FailoverTransport implements CompositeTransport { private final Object reconnectMutex = new Object(); private final Object backupMutex = new Object(); private final Object sleepMutex = new Object(); + private final Object listenerMutex = new Object(); private final ConnectionStateTracker stateTracker = new ConnectionStateTracker(); private final Map requestMap = new LinkedHashMap(); @@ -564,7 +565,10 @@ public class FailoverTransport implements CompositeTransport { } public void setTransportListener(TransportListener commandListener) { - this.transportListener = commandListener; + synchronized(listenerMutex) { + this.transportListener = commandListener; + listenerMutex.notifyAll(); + } } public T narrow(Class target) { @@ -683,8 +687,21 @@ public class FailoverTransport implements CompositeTransport { connectedTransport.set(t); reconnectMutex.notifyAll(); connectFailures = 0; + // Make sure on initial startup, that the transportListener + // has been initialized for this instance. + synchronized(listenerMutex) { + if (transportListener==null) { + try { + //if it isn't set after 2secs - it + //probably never will be + listenerMutex.wait(2000); + }catch(InterruptedException ex) {} + } + } if (transportListener != null) { transportListener.transportResumed(); + }else { + LOG.debug("transport resumed by transport listener not set"); } if (firstConnection) { firstConnection=false;