Browse Source

DefaultMessageListenerContainer's recovery phase uses wait instead of sleep

Issue: SPR-14200
pull/1046/head
Juergen Hoeller 9 years ago
parent
commit
6ab8d36ed0
  1. 14
      spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

14
spring-jms/src/main/java/org/springframework/jms/listener/DefaultMessageListenerContainer.java

@ -989,7 +989,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe @@ -989,7 +989,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
}
else {
try {
Thread.sleep(interval);
synchronized (this.lifecycleMonitor) {
this.lifecycleMonitor.wait(interval);
}
}
catch (InterruptedException interEx) {
// Re-interrupt current thread, to allow other threads to react.
@ -1057,9 +1059,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe @@ -1057,9 +1059,9 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
catch (Throwable ex) {
clearResources();
if (!this.lastMessageSucceeded) {
// We failed more than once in a row or on startup - sleep before
// first recovery attempt.
sleepBeforeRecoveryAttempt();
// We failed more than once in a row or on startup -
// wait before first recovery attempt.
waitBeforeRecoveryAttempt();
}
this.lastMessageSucceeded = false;
boolean alreadyRecovered = false;
@ -1214,11 +1216,11 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe @@ -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
* 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
* specific).
*/
private void sleepBeforeRecoveryAttempt() {
private void waitBeforeRecoveryAttempt() {
BackOffExecution execution = DefaultMessageListenerContainer.this.backOff.start();
applyBackOffTime(execution);
}

Loading…
Cancel
Save