git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@663680 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2008-06-05 17:57:55 +00:00
parent aee5d25e41
commit f7fa2bc58d
1 changed files with 18 additions and 1 deletions

View File

@ -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<Integer, Command> requestMap = new LinkedHashMap<Integer, Command>();
@ -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> T narrow(Class<T> 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;