in qpid-jms-client/src/main/java/org/apache/qpid/jms/provider/failover/FailoverProvider.java [714:789]
private void triggerReconnectionAttempt() {
if (closingConnection.get() || closed.get() || failed.get()) {
return;
}
reconnectControl.scheduleReconnect(new Runnable() {
@Override
public void run() {
if (provider != null || closingConnection.get() || closed.get() || failed.get()) {
return;
}
ProviderException failure = null;
Provider provider = null;
long reconnectAttempts = reconnectControl.recordNextAttempt();
try {
if (!uris.isEmpty()) {
for (int i = 0; i < uris.size(); ++i) {
URI target = uris.getNext();
if (target == null) {
LOG.trace("Failover URI collection unexpectedly modified during connection attempt.");
failure = ProviderExceptionSupport.createOrPassthroughFatal(
new ConcurrentModificationException("Failover URIs changed unexpectedly"));
continue;
}
try {
LOG.debug("Connection attempt:[{}] to: {} in-progress", reconnectAttempts,
target.getScheme() + "://" + target.getHost() + ":" + target.getPort());
provider = ProviderFactory.create(target, futureFactory);
provider.connect(connectionInfo);
initializeNewConnection(provider);
return;
} catch (Throwable e) {
LOG.info("Connection attempt:[{}] to: {} failed", reconnectAttempts,
target.getScheme() + "://" + target.getHost() + ":" + target.getPort());
failure = ProviderExceptionSupport.createOrPassthroughFatal(e);
try {
if (provider != null) {
provider.close();
}
} catch (Throwable ex) {
} finally {
provider = null;
}
if (reconnectControl.isStoppageCause(failure)) {
LOG.trace("Stopping attempt due to type of failure");
break;
}
}
}
} else {
LOG.debug("No remote URI available to connect to in failover list");
failure = new ProviderFailedException(
"No remote URI available for reconnection during connection attempt: " + reconnectAttempts);
}
} catch (Throwable unknownFailure) {
LOG.warn("Connection attempt:[{}] failed abnormally.", reconnectAttempts);
failure = failure == null ? ProviderExceptionSupport.createOrPassthroughFatal(unknownFailure) : failure;
} finally {
if (provider == null) {
LOG.trace("Connection attempt:[{}] failed error: {}", reconnectControl.reconnectAttempts, failure.getMessage());
if (!reconnectControl.isReconnectAllowed(failure)) {
reportReconnectFailure(failure);
} else {
reconnectControl.scheduleReconnect(this);
}
}
}
}
});
}