Error handling and dead-letter topics
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
keep a poison record from blocking a partition.
Planned topics
- An exception in a listener hits the error handler; the default
DefaultErrorHandlerretries with a back-off, then skips (logs). - Configure
DeadLetterPublishingRecovererto send failed records to<topic>.DLT. - Classify errors: retry transient ones (timeouts), send non-retryable ones (bad payload) straight to the DLT.
- Non-blocking retry topics are available through
@RetryableTopic(verify support for your version). - Monitor DLT size and keep the failure headers for diagnosis.
Draft outline details
Demonstration
@Bean DefaultErrorHandler errors(KafkaTemplate<Object,Object> t) {
return new DefaultErrorHandler(new DeadLetterPublishingRecoverer(t), new FixedBackOff(1000L, 3));
}Check your understanding
Where does a record go after retries are exhausted?
Show answer
To the dead-letter topic.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.