Skip to content

Commit

Permalink
https://issues.apache.org/jira/browse/AMQ-6273
Browse files Browse the repository at this point in the history
increment the connect attempt count explicitly to ensure reconnect
policy options are applied.
  • Loading branch information
tabish121 committed Jul 19, 2016
1 parent 39184e2 commit e05db7c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,9 @@ private void doInitializeConnection(boolean local) throws Exception {
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) {
}
}
Expand Down Expand Up @@ -625,9 +627,11 @@ private void doInitializeConnection(boolean local) throws Exception {
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public long getNextDelay(int attempt) {
long nextDelay = initialReconnectDelay;

if (useExponentialBackOff) {
nextDelay = nextDelay * (long)(attempt * backOffMultiplier);
nextDelay = Math.max(initialReconnectDelay, nextDelay * (long)((attempt - 1) * backOffMultiplier));
}

if (maximumReconnectDelay > 0 && nextDelay > maximumReconnectDelay) {
Expand Down

0 comments on commit e05db7c

Please sign in to comment.