Don't attempt to reconnect if serverSessionPool is closing

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@374118 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-02-01 17:21:47 +00:00
parent 7f634906d0
commit d8bdbe7a7c
2 changed files with 31 additions and 18 deletions

View File

@ -232,24 +232,23 @@ public class ActiveMQEndpointWorker {
connection=null;
}
synchronized private void reconnect(JMSException error) {
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());
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) {
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());
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){}
}
}

View File

@ -199,4 +199,18 @@ public class ServerSessionPoolImpl implements ServerSessionPool {
}
}
/**
* @return Returns the closing.
*/
public boolean isClosing(){
return closing;
}
/**
* @param closing The closing to set.
*/
public void setClosing(boolean closing){
this.closing=closing;
}
}