diff --git a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQEndpointWorker.java b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQEndpointWorker.java index 81a2277149..e1cc5bc220 100755 --- a/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQEndpointWorker.java +++ b/activemq-ra/src/main/java/org/apache/activemq/ra/ActiveMQEndpointWorker.java @@ -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); - // 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"); + 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); - // Use exponential rollback. - reconnectDelay*=2; - if (reconnectDelay > MAX_RECONNECT_DELAY) - reconnectDelay=MAX_RECONNECT_DELAY; + + synchronized(this) { + // Use exponential rollback. + this.reconnectDelay*=2; + if (this.reconnectDelay > MAX_RECONNECT_DELAY) + this.reconnectDelay=MAX_RECONNECT_DELAY; + } connect(); } catch(InterruptedException e) {} }