Apache Kafka Tutorial 0/111 lessons ~6 min read Lesson 84
Retry Topics
What is Retry Topics?
Course progress0%
Focus
9 guided sections
Practice signal
Examples included
Career prep
Foundation builder
Introduction
What is Retry Topics? Retry topics move failed records through delayed retry topics before sending them to a dead letter topic.
Understanding the topic
What happens — Retry Topics:
- Classify retryable vs poison errors.
- Retry with backoff for transient failures.
- Route poison messages to DLT.
- Alert and replay from DLT after fix.
| Term | Description |
|---|---|
| DLT | Dead letter topic for failed records. |
| Retry topic | Delayed reprocessing queue. |
| Poison message | Always fails processing. |
| Idempotent handler | Safe on duplicate delivery. |
Visual explanation
Pipeline view:
text
KafkaTemplate↓topic↓@KafkaListener container↓service logic↓ack/retry/DLT
Step-by-step explanation
- Catch error — In listener or poll loop.
- Retry — Backoff N times.
- DLT — Publish with failure metadata.
- Alert — Page on DLT growth.
Informative example
Example:
bash
kafka-topics --bootstrap-server localhost:9092 --create --topic retry-topics --partitions 6 --replication-factor 3kafka-console-producer --bootstrap-server localhost:9092 --topic retry-topicskafka-console-consumer --bootstrap-server localhost:9092 --topic retry-topics --from-beginningkafka-consumer-groups --bootstrap-server localhost:9092 --describe --group retry-topics-service
Execution workflow
1Retry Topics workflow
1 / 4Catch error
In listener or poll loop.
Best practices
- Use typed event classes and schema validation.
- Use manual or record ack modes for critical processing.
- Add retry topics and DLT with alerts.
- Test with embedded Kafka or Testcontainers.
Common mistakes
- Doing slow blocking work inside listener threads without concurrency planning.
- Catching exceptions and still acknowledging bad records.
- No DLT monitoring.
Summary
Retry Topics — Configure listener containers intentionally: ack mode, concurrency, error handling, retries, DLT, observability, and idempotent processing.
Ready to mark this lesson complete?Track your journey across the entire course.