DefaultMessageListenerContainer's recovery phase uses wait instead of sleep
Issue: SPR-14200
This commit is contained in:
@@ -989,7 +989,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(interval);
|
synchronized (this.lifecycleMonitor) {
|
||||||
|
this.lifecycleMonitor.wait(interval);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (InterruptedException interEx) {
|
catch (InterruptedException interEx) {
|
||||||
// Re-interrupt current thread, to allow other threads to react.
|
// Re-interrupt current thread, to allow other threads to react.
|
||||||
@@ -1057,9 +1059,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
|||||||
catch (Throwable ex) {
|
catch (Throwable ex) {
|
||||||
clearResources();
|
clearResources();
|
||||||
if (!this.lastMessageSucceeded) {
|
if (!this.lastMessageSucceeded) {
|
||||||
// We failed more than once in a row or on startup - sleep before
|
// We failed more than once in a row or on startup -
|
||||||
// first recovery attempt.
|
// wait before first recovery attempt.
|
||||||
sleepBeforeRecoveryAttempt();
|
waitBeforeRecoveryAttempt();
|
||||||
}
|
}
|
||||||
this.lastMessageSucceeded = false;
|
this.lastMessageSucceeded = false;
|
||||||
boolean alreadyRecovered = false;
|
boolean alreadyRecovered = false;
|
||||||
@@ -1214,11 +1216,11 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply the back-off time once. In a regular scenario, the back-off is only applied if we
|
* Apply the back-off time once. In a regular scenario, the back-off is only applied if we
|
||||||
* failed to recover with the broker. This additional sleep period avoids a burst retry
|
* failed to recover with the broker. This additional wait period avoids a burst retry
|
||||||
* scenario when the broker is actually up but something else if failing (i.e. listener
|
* scenario when the broker is actually up but something else if failing (i.e. listener
|
||||||
* specific).
|
* specific).
|
||||||
*/
|
*/
|
||||||
private void sleepBeforeRecoveryAttempt() {
|
private void waitBeforeRecoveryAttempt() {
|
||||||
BackOffExecution execution = DefaultMessageListenerContainer.this.backOff.start();
|
BackOffExecution execution = DefaultMessageListenerContainer.this.backOff.start();
|
||||||
applyBackOffTime(execution);
|
applyBackOffTime(execution);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user