Skip to content
Kafka Is FunProgress

SpringSpring Kafka Error Handling

How do you configure retry and dead letter topics in Spring Kafka?

Reference answer

Using @RetryableTopic annotation: @RetryableTopic(attempts = 4, backoff = @Backoff(delay = 1000, multiplier = 2), dltTopicSuffix = '-dlt'). This creates retry topics (my-topic-retry-0, my-topic-retry-1, etc.) and a DLT (my-topic-dlt). Failed messages flow through retries with backoff then land in DLT. Or configure programmatically via ConcurrentKafkaListenerContainerFactory with a DefaultErrorHandler + DeadLetterPublishingRecoverer. The DLT message includes original exception info in headers.

Expected key concepts: @RetryableTopic, attempts, @Backoff, delay, multiplier, dltTopicSuffix, retry topics, DLT, DefaultErrorHandler, DeadLetterPublishingRecoverer, headers