I have Kafka listener writing data to a database, in case of database timeout (JdbcException), I'd like to retry, and if timeouts persist, stop consuming Kafka message.
As far as I understand, Spring Kafka 2.9 has 2 CommonErrorHandler
implementations:
I would like to chain both of them: first try to redeliver messages several times, then stop container when delivery doesn't succeed.
How can I do that?
Use a DefaultErrorHandler
with a custom recoverer that calls a CommonContainerStoppingErrorHandler
after the retries are exhausted.
See this answer for an example
(It uses the older SeekToCurrentErrorHandler
, but the same concept applies.)