How to retry for fixed amount of time after all previous retries are exhausted in Kafka consumer?

801 views Asked by At

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?

1

There are 1 answers

0
Gary Russell On BEST ANSWER

Assuming you are using the ExponentialBackOffPolicy in the RetryTemplate, you can set its maxInterval property.

If you are using a SeekToCurrentErrorHandler with an ExponentialBackOff instead (which is preferred with modern versions of spring-kafka - to avoid a rebalance), it, too, has a maxInterval property.