Add back-off attribute to JMS namespace
This commit adds a "back-off" attribute to the jms:listener-container element so that a BackOff instance can be provided for users of the XML namespace. Issue: SPR-11746
This commit is contained in:
@@ -54,6 +54,8 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
|
||||
|
||||
private static final String RECOVERY_INTERVAL_ATTRIBUTE = "recovery-interval";
|
||||
|
||||
private static final String BACK_OFF_ATTRIBUTE = "back-off";
|
||||
|
||||
|
||||
protected PropertyValues parseProperties(Element containerEle, ParserContext parserContext) {
|
||||
final MutablePropertyValues properties = new MutablePropertyValues();
|
||||
@@ -223,10 +225,18 @@ class JmsListenerContainerParser extends AbstractListenerContainerParser {
|
||||
}
|
||||
}
|
||||
|
||||
String recoveryInterval = containerEle.getAttribute(RECOVERY_INTERVAL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(recoveryInterval)) {
|
||||
String backOffBeanName = containerEle.getAttribute(BACK_OFF_ATTRIBUTE);
|
||||
if (StringUtils.hasText(backOffBeanName)) {
|
||||
if (!isSimpleContainer) {
|
||||
propertyValues.add("recoveryInterval", recoveryInterval);
|
||||
propertyValues.add("backOff", new RuntimeBeanReference(backOffBeanName));
|
||||
}
|
||||
}
|
||||
else { // No need to consider this if back-off is set
|
||||
String recoveryInterval = containerEle.getAttribute(RECOVERY_INTERVAL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(recoveryInterval)) {
|
||||
if (!isSimpleContainer) {
|
||||
propertyValues.add("recoveryInterval", recoveryInterval);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +224,8 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||
* between recovery attempts. If the {@link BackOff} implementation
|
||||
* returns {@link BackOff#STOP}, this listener container will not further
|
||||
* attempt to recover.
|
||||
* <p>The {@link #setRecoveryInterval(long) recovery interval} is ignored
|
||||
* when this property is set.
|
||||
*/
|
||||
public void setBackOff(BackOff backOff) {
|
||||
this.backOff = backOff;
|
||||
@@ -231,9 +233,10 @@ public class DefaultMessageListenerContainer extends AbstractPollingMessageListe
|
||||
|
||||
/**
|
||||
* Specify the interval between recovery attempts, in <b>milliseconds</b>.
|
||||
* The default is 5000 ms, that is, 5 seconds.
|
||||
* <p>This is a convenience method to create a {@link FixedBackOff} with
|
||||
* the specified interval.
|
||||
* The default is 5000 ms, that is, 5 seconds. This is a convenience method
|
||||
* to create a {@link FixedBackOff} with the specified interval.
|
||||
* <p>For more recovery options, consider specifying a {@link BackOff}
|
||||
* instance instead.
|
||||
* @see #setBackOff(BackOff)
|
||||
* @see #handleListenerSetupFailure
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user