Search code examples
apache-cameljbossfusefuseesb

Camel useExponentialBackoff not working correctly


I have setup a camel routing with an errorHandler and redelivery policy configured as below

<errorHandler id="apiRetryHandler" type="DefaultErrorHandler">
<redeliveryPolicy maximumRedeliveries="5" redeliveryDelay="30000"
backOffMultiplier="5" useExponentialBackOff="true"
useCollisionAvoidance="true"/><errorHandler>

I am expecting the following outcome

  • Message 1 -> Actual message
  • Message 2 -> 1st Retry = 30 Seconds
  • Message 3 -> 2nd Retry (30 [redeliveryDelay] x 5 [backoffMultipler]) = 2.5 mins
  • Message 4 -> 3rd Retry ( 2.5 mins (previous) x 5 [backoffMultipler]) = 12.5 mins

On the first failure, when I receive an exception from the system, the handler kicks in the following order

  • 1st Retry - 30 seconds
  • 2nd Retry - 1 min
  • 3rd Retry - 1 min ...
  • 6th Retry - 1 min

Please advice what I am doing wrong here.


Solution

  • There is a maximum redelivery delay of 60 seconds [1]. You need to set that to a higher value. Also its is not recommended to use long delay values, eg 12.5 minutes is a very long time.

    <errorHandler id="apiRetryHandler" type="DefaultErrorHandler">
    <redeliveryPolicy maximumRedeliveryDelay="30min" maximumRedeliveries="5" redeliveryDelay="30sec"
    backOffMultiplier="5" useExponentialBackOff="true"
    useCollisionAvoidance="true"/><errorHandler>