mirror of https://github.com/apache/activemq.git
Need to check if the server pool is closing before calling reconnect, as the method is synchronized and can cause deadlocks
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@374119 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d8bdbe7a7c
commit
d1b05c4f23
|
@ -145,7 +145,9 @@ public class ActiveMQEndpointWorker {
|
||||||
connection.start();
|
connection.start();
|
||||||
connection.setExceptionListener(new ExceptionListener() {
|
connection.setExceptionListener(new ExceptionListener() {
|
||||||
public void onException(JMSException error) {
|
public void onException(JMSException error) {
|
||||||
reconnect(error);
|
if (!serverSessionPool.isClosing()) {
|
||||||
|
reconnect(error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -233,23 +235,21 @@ public class ActiveMQEndpointWorker {
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized private void reconnect(JMSException error){
|
synchronized private void reconnect(JMSException error){
|
||||||
if(!serverSessionPool.isClosing()){
|
log.debug("Reconnect cause: ",error);
|
||||||
log.debug("Reconnect cause: ",error);
|
// Only log errors if the server is really down.. And not a temp failure.
|
||||||
// Only log errors if the server is really down.. And not a temp failure.
|
if (reconnectDelay == MAX_RECONNECT_DELAY) {
|
||||||
if(reconnectDelay==MAX_RECONNECT_DELAY){
|
log.info("Endpoint connection to JMS broker failed: " + error.getMessage());
|
||||||
log.info("Endpoint connection to JMS broker failed: "+error.getMessage());
|
log.info("Endpoint will try to reconnect to the JMS broker in "+(MAX_RECONNECT_DELAY/1000)+" seconds");
|
||||||
log.info("Endpoint will try to reconnect to the JMS broker in "+(MAX_RECONNECT_DELAY/1000)+" seconds");
|
|
||||||
}
|
|
||||||
try{
|
|
||||||
disconnect();
|
|
||||||
Thread.sleep(reconnectDelay);
|
|
||||||
// Use exponential rollback.
|
|
||||||
reconnectDelay*=2;
|
|
||||||
if(reconnectDelay>MAX_RECONNECT_DELAY)
|
|
||||||
reconnectDelay=MAX_RECONNECT_DELAY;
|
|
||||||
connect();
|
|
||||||
}catch(InterruptedException e){}
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
disconnect();
|
||||||
|
Thread.sleep(reconnectDelay);
|
||||||
|
// Use exponential rollback.
|
||||||
|
reconnectDelay*=2;
|
||||||
|
if (reconnectDelay > MAX_RECONNECT_DELAY)
|
||||||
|
reconnectDelay=MAX_RECONNECT_DELAY;
|
||||||
|
connect();
|
||||||
|
} catch(InterruptedException e) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerThreadSession(Session session) {
|
protected void registerThreadSession(Session session) {
|
||||||
|
|
Loading…
Reference in New Issue