diff options
-rw-r--r-- | qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java index 69ddf7b08f..f6537e0375 100644 --- a/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java +++ b/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnection.java @@ -369,7 +369,8 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect } _failoverPolicy = new FailoverPolicy(connectionURL); - if (_failoverPolicy.getNextBrokerDetails().getTransport().equals(BrokerDetails.VM)) + BrokerDetails brokerDetails = _failoverPolicy.getNextBrokerDetails(); + if (brokerDetails.getTransport().equals(BrokerDetails.VM)) { _delegate = new AMQConnectionDelegate_0_8(this); } @@ -450,11 +451,15 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect Exception lastException = new Exception(); lastException.initCause(new ConnectException()); - while (!_connected && _failoverPolicy.failoverAllowed()) + // TMG FIXME this seems... wrong... + boolean retryAllowed = true; + while (!_connected && retryAllowed ) { try { - makeBrokerConnection(_failoverPolicy.getNextBrokerDetails()); + makeBrokerConnection(brokerDetails); + lastException = null; + _connected = true; } catch (AMQProtocolException pe) { @@ -472,16 +477,13 @@ public class AMQConnection extends Closeable implements Connection, QueueConnect { lastException = e; - //We need to change protocol handler here as an error during the connect will not - // cause the StateManager to be replaced. So the state is out of sync on reconnect - // This can be seen when a exception occurs during connection. i.e. log4j NoSuchMethod. (using < 1.2.12) - _protocolHandler.setStateManager(new AMQStateManager()); - if (_logger.isInfoEnabled()) { _logger.info("Unable to connect to broker at " + _failoverPolicy.getCurrentBrokerDetails(), - e.getCause()); + e.getCause()); } + retryAllowed = _failoverPolicy.failoverAllowed(); + brokerDetails = _failoverPolicy.getNextBrokerDetails(); } } |