I am using exponential retry in Kafka consumer. And it is working as expected but I need to add some more configuration to it. Suppose after the maximum retry attempt, the request is still not successful then I need to retry it for a fixed time thereafter.
Suppose the multiplier is 2 and the maximum retry attempt is 4 with an initial retry interval 1sec
Then retry sequence will be
1sec, 2 sec, 4 sec, 8 sec.
After the fourth attempt, I need retry to occur at a fixed interval (say after each 10sec) until the request is successful.
Is there any way I can achieve this?
How to retry for fixed amount of time after all previous retries are exhausted in Kafka consumer?
814 views Asked by Suhaas At
1
Assuming you are using the
ExponentialBackOffPolicy
in theRetryTemplate
, you can set itsmaxInterval
property.If you are using a
SeekToCurrentErrorHandler
with anExponentialBackOff
instead (which is preferred with modern versions of spring-kafka - to avoid a rebalance), it, too, has amaxInterval
property.