Polishing

This commit is contained in:
Juergen Hoeller
2016-02-04 20:00:00 +01:00
parent f108deb114
commit e90310612f
4 changed files with 24 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -175,7 +175,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
private Executor taskExecutor;
private BackOff backOff = createDefaultBackOff(DEFAULT_RECOVERY_INTERVAL);
private BackOff backOff = new FixedBackOff(DEFAULT_RECOVERY_INTERVAL, Long.MAX_VALUE);
private int cacheLevel = CACHE_AUTO;
@@ -229,6 +229,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
* attempt to recover.
* <p>The {@link #setRecoveryInterval(long) recovery interval} is ignored
* when this property is set.
* @since 4.1
*/
public void setBackOff(BackOff backOff) {
this.backOff = backOff;
@@ -244,7 +245,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
* @see #handleListenerSetupFailure
*/
public void setRecoveryInterval(long recoveryInterval) {
this.backOff = createDefaultBackOff(recoveryInterval);
this.backOff = new FixedBackOff(recoveryInterval, Long.MAX_VALUE);
}
/**
@@ -941,7 +942,7 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
StringBuilder msg = new StringBuilder();
msg.append("Stopping container for destination '")
.append(getDestinationDescription())
.append("' - back off policy does not allow ").append("for further attempts.");
.append("': back-off policy does not allow ").append("for further attempts.");
logger.error(msg.toString());
stop();
}
@@ -968,10 +969,11 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
}
/**
* Apply the next back off time using the specified {@link BackOffExecution}.
* <p>Return {@code true} if the back off period has been applied and a new
* Apply the next back-off time using the specified {@link BackOffExecution}.
* <p>Return {@code true} if the back-off period has been applied and a new
* attempt to recover should be made, {@code false} if no further attempt
* should be made.
* @since 4.1
*/
protected boolean applyBackOffTime(BackOffExecution execution) {
long interval = execution.nextBackOff();
@@ -990,10 +992,6 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
return true;
}
private FixedBackOff createDefaultBackOff(long interval) {
return new FixedBackOff(interval, Long.MAX_VALUE);
}
/**
* Return whether this listener container is currently in a recovery attempt.
* <p>May be used to detect recovery phases but also the end of a recovery phase,
@@ -1205,7 +1203,7 @@ 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
* scenario when the broker is actually up but something else if failing (i.e. listener
* specific).