git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@391694 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Hiram R. Chirino 2006-04-05 18:12:05 +00:00
parent 3b1a7d66de
commit 97f2ca1eef
1 changed files with 16 additions and 9 deletions

View File

@ -234,20 +234,27 @@ public class ActiveMQEndpointWorker {
connection=null;
}
synchronized private void reconnect(JMSException error){
private void reconnect(JMSException error){
log.debug("Reconnect cause: ",error);
long reconnectDelay;
synchronized(this) {
reconnectDelay = this.reconnectDelay;
// 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);
synchronized(this) {
// Use exponential rollback.
reconnectDelay*=2;
if (reconnectDelay > MAX_RECONNECT_DELAY)
reconnectDelay=MAX_RECONNECT_DELAY;
this.reconnectDelay*=2;
if (this.reconnectDelay > MAX_RECONNECT_DELAY)
this.reconnectDelay=MAX_RECONNECT_DELAY;
}
connect();
} catch(InterruptedException e) {}
}