Better failover error handling and now we pass on the max initial inactivity timeout to the timeout used by the intial wire format negociation.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@640641 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2008-03-24 23:19:50 +00:00
parent 0a4c8064e4
commit c04d8c548d
2 changed files with 27 additions and 29 deletions

View File

@ -57,6 +57,13 @@ public class WireFormatNegotiator extends TransportFilter {
minimumVersion = 1;
}
this.minimumVersion = minimumVersion;
// Setup the initial negociation timeout to be the same as the inital max inactivity delay specified on the wireformat
// Does not make sense for us to take longer.
try {
setNegotiateTimeout(wireFormat.getPreferedWireFormatInfo().getMaxInactivityDurationInitalDelay());
} catch (IOException e) {
}
}
public void start() throws Exception {

View File

@ -94,7 +94,7 @@ public class FailoverTransport implements CompositeTransport {
private int backupPoolSize=1;
private boolean trackMessages = false;
private int maxCacheSize = 128 * 1024;
private TransportListener disposedListener = new DefaultTransportListener();
private TransportListener disposedListener = new DefaultTransportListener() {};
private final TransportListener myTransportListener = createTransportListener();
@ -189,12 +189,12 @@ public class FailoverTransport implements CompositeTransport {
public final void handleTransportFailure(IOException e) throws InterruptedException {
Transport transport = connectedTransport.get();
Transport transport = connectedTransport.getAndSet(null);
if( transport!=null ) {
ServiceSupport.dispose(transport);
}
boolean wasConnected=false;
transport.setTransportListener(disposedListener);
ServiceSupport.dispose(transport);
synchronized (reconnectMutex) {
boolean reconnectOk = false;
if(started) {
@ -203,29 +203,20 @@ public class FailoverTransport implements CompositeTransport {
reconnectOk = true;
}
if (connectedTransport.get() != null) {
wasConnected=true;
initialized = false;
failedConnectTransportURI=connectedTransportURI;
Transport old = connectedTransport.get();
if(old != null) {
//don't want errors from old transport
old.setTransportListener(disposedListener);
}
connectedTransport.set(null);
connectedTransportURI = null;
connected=false;
}
if(reconnectOk) {
reconnectTask.wakeup();
}
}
// Avoid double firing a transportInterupted() event due to an extra IOException
if (transportListener != null && wasConnected) {
if (transportListener != null) {
transportListener.transportInterupted();
}
}
}