mirror of https://github.com/apache/activemq.git
increment the connect attempt count explicitly to ensure reconnect policy options are applied.
This commit is contained in:
parent
39184e2fb0
commit
e05db7cb5c
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue