increment the connect attempt count explicitly to ensure reconnect
policy options are applied.
This commit is contained in:
Timothy Bish 2016-07-19 17:26:24 -04:00
parent 39184e2fb0
commit e05db7cb5c
2 changed files with 7 additions and 3 deletions

View File

@ -593,7 +593,9 @@ public abstract class JmsConnector implements Service {
do {
if (attempt > 0) {
try {
Thread.sleep(policy.getNextDelay(attempt));
long nextDelay = policy.getNextDelay(attempt);
LOG.debug("Bridge reconnect attempt {} waiting {}ms before next attempt.", attempt, nextDelay);
Thread.sleep(nextDelay);
} catch(InterruptedException e) {
}
}
@ -625,9 +627,11 @@ public abstract class JmsConnector implements Service {
return;
} catch(Exception e) {
LOG.debug("Failed to establish initial {} connection for JmsConnector [{}]", new Object[]{ (local ? "local" : "foreign"), attempt }, e);
} finally {
attempt++;
}
}
while ((maxRetries == INFINITE || maxRetries > ++attempt) && !connectionService.isShutdown());
while ((maxRetries == INFINITE || maxRetries > attempt) && !connectionService.isShutdown());
this.failed.set(true);
}

View File

@ -234,7 +234,7 @@ public class ReconnectionPolicy {
long nextDelay = initialReconnectDelay;
if (useExponentialBackOff) {
nextDelay = nextDelay * (long)(attempt * backOffMultiplier);
nextDelay = Math.max(initialReconnectDelay, nextDelay * (long)((attempt - 1) * backOffMultiplier));
}
if (maximumReconnectDelay > 0 && nextDelay > maximumReconnectDelay) {