[AMQ-6792] fire the failover exception handler before stop to ensure blocked write does not block stop request

This commit is contained in:
gtully 2017-08-11 12:58:51 +01:00
parent 068b7946ce
commit 63f0b7e20d
1 changed files with 12 additions and 0 deletions

View File

@ -93,6 +93,7 @@ import org.apache.activemq.transport.ResponseCallback;
import org.apache.activemq.transport.Transport;
import org.apache.activemq.transport.TransportDisposedIOException;
import org.apache.activemq.transport.TransportFilter;
import org.apache.activemq.transport.failover.FailoverTransport;
import org.apache.activemq.transport.tcp.SslTransport;
import org.apache.activemq.transport.tcp.TcpTransport;
import org.apache.activemq.util.IdGenerator;
@ -323,6 +324,7 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
} finally {
ServiceStopper ss = new ServiceStopper();
stopFailoverTransport(remoteBroker);
ss.stop(remoteBroker);
ss.stop(localBroker);
ss.stop(duplexInboundLocalBroker);
@ -341,6 +343,16 @@ public abstract class DemandForwardingBridgeSupport implements NetworkBridge, Br
}
}
private void stopFailoverTransport(Transport transport) {
FailoverTransport failoverTransport = transport.narrow(FailoverTransport.class);
if (failoverTransport != null) {
// may be blocked on write, in which case stop will block
try {
failoverTransport.handleTransportFailure(new IOException("Bridge stopped"));
} catch (InterruptedException ignored) {}
}
}
protected void triggerStartAsyncNetworkBridgeCreation() throws IOException {
brokerService.getTaskRunnerFactory().execute(new Runnable() {
@Override