The retry is specified as follows:
<bean id="retryAdvice"
class="org.springframework.integration.handler.advice.RequestHandlerRetryAdvice" >
<property name="retryTemplate">
<bean class="org.springframework.retry.support.RetryTemplate">
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="5000"/>
<property name="multiplier" value="3.0"/>
</bean>
</property>
<property name="retryPolicy">
<bean class="org.springframework.retry.policy.SimpleRetryPolicy">
<property name="maxAttempts" value="6" />
</bean>
</property>
</bean>
</property>
</bean>
I expected that the interval would be increased by 3 times with every attempt. In reality I got the following intervals: 5, 15, 30, 30, 30 seconds. See the exact times and intervals below. What did I specify incorrectly?
2016-05-10 10:07:49,714 - 0
2016-05-10 10:07:55,085 - 5.2
2016-05-10 10:08:10,457 - 15.4
2016-05-10 10:08:40,830 - 30.4
2016-05-10 10:09:11,230 - 30.4
2016-05-10 10:09:41,639 - 30.4
There is maxInterval
to consider:
/**
* Setter for maximum back off period. Default is 30000 (30 seconds). the
* value will be reset to 1 if this method is called with a value less than
* 1. Set this to avoid infinite waits if backing off a large number of
* times (or if the multiplier is set too high).
*
* @param maxInterval in milliseconds.
*/
public void setMaxInterval(long maxInterval) {
this.maxInterval = maxInterval > 0 ? maxInterval : 1;
}
So, when your ExponentialBackOffPolicy
reaches 30 secs
(default) it stops to use multiplier
afterwards.
Increase the max interval to allow the multiplier to take effect.
<bean id="retryTemplate" class="org.springframework.retry.support.RetryTemplate">
<property name="retryPolicy">
<bean class="RetryPolicy"
p:skipRetryFaults="${retry.skipForFaults}"
p:maxAttempts="${retry.maxAttempts}"/>
</property>
<property name="backOffPolicy">
<bean class="org.springframework.retry.backoff.ExponentialBackOffPolicy">
<property name="initialInterval" value="${backoff.initialInterval}" />
<property name="maxInterval" value="${backoff.maxInterval}" />
<property name="multiplier" value="${backoff.multiplier}" />
</bean>
</property>
</bean>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With