From d1b05c4f23d875e979dd4a6d1a00a69dd48d63d9 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Wed, 1 Feb 2006 17:29:05 +0000 Subject: [PATCH] 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 --- .../activemq/ra/ActiveMQEndpointWorker.java | 34 +++++++++---------- 1 file changed, 17 insertions(+), 17 deletions(-) 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 b9b974c57d..81a2277149 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 @@ -145,7 +145,9 @@ public class ActiveMQEndpointWorker { connection.start(); connection.setExceptionListener(new ExceptionListener() { 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){ - 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){} + 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) {} } protected void registerThreadSession(Session session) {