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:
Guillaume Nodet 2006-02-01 17:29:05 +00:00
parent d8bdbe7a7c
commit d1b05c4f23
1 changed files with 17 additions and 17 deletions

View File

@ -145,8 +145,10 @@ public class ActiveMQEndpointWorker {
connection.start();
connection.setExceptionListener(new ExceptionListener() {
public void onException(JMSException error) {
if (!serverSessionPool.isClosing()) {
reconnect(error);
}
}
});
if (activationSpec.isDurableSubscription()) {
@ -233,23 +235,21 @@ public class ActiveMQEndpointWorker {
}
synchronized private void reconnect(JMSException error){
if(!serverSessionPool.isClosing()){
log.debug("Reconnect cause: ",error);
// Only log errors if the server is really down.. And not a temp failure.
if(reconnectDelay==MAX_RECONNECT_DELAY){
log.info("Endpoint connection to JMS broker failed: "+error.getMessage());
if (reconnectDelay == MAX_RECONNECT_DELAY) {
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");
}
try{
try {
disconnect();
Thread.sleep(reconnectDelay);
// Use exponential rollback.
reconnectDelay*=2;
if(reconnectDelay>MAX_RECONNECT_DELAY)
if (reconnectDelay > MAX_RECONNECT_DELAY)
reconnectDelay=MAX_RECONNECT_DELAY;
connect();
}catch(InterruptedException e){}
}
} catch(InterruptedException e) {}
}
protected void registerThreadSession(Session session) {