I am not able to find how to do custom error handling in for a spring kafka consumer.
My requirement is:
- For any deserialization errors, just write the error and message to database.
- For any errors in execution under
@KafkaListener
method, retry 3 times and then write the error and message to database.
From the spring docs, I found that,
For 1, I will have to use ErrorHandlingDeserializer
and it will then call the @KafkaListener error handler.
For 2, framework provides SeekToCurrentErrorHandler
which handles message retries.
I am not understanding where can I add the code to write the exception/message to database in addition to enable configured retries.