Skip to content
Ameen Abozaid
Planned lessonMID-029-L05

Retries, backoff, and DLQs

  • Lesson 5 of 7
  • Mid-level
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

retry transient failures sensibly and park permanent ones.

Planned topics

  • Transient failures (timeout, deadlock) deserve a retry; permanent ones (bad payload, rule violation) never succeed.
  • Use exponential backoff with a maximum attempt count; blocking retries stall the partition, so use retry topics for long delays.
  • After the limit, send the message to a dead-letter queue (DLQ) with the error and original headers.
  • Alert on DLQ depth and provide a way to replay after the fix.
  • Spring Kafka offers DefaultErrorHandler with backoff and a dead-letter recoverer (verify version before recording).
Draft outline details

Demonstration

java
var handler = new DefaultErrorHandler(
    new DeadLetterPublishingRecoverer(template),
    new ExponentialBackOff(500, 2.0)); // add a max elapsed time or attempts

Check your understanding

Why should a malformed payload go straight to the DLQ?

Show answer

Retrying cannot fix it and only delays the messages behind it.

Practice

Apply this lesson with the module's lab, exercises and quiz.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.