Non-Blocking Retries, Delay Topics Ladder, and DLT
Implement high-throughput non-blocking retries with Spring Kafka's @RetryableTopic, architect delay topic ladders, and prevent head-of-line blocking.
In high-throughput event streaming systems, standard in-memory retries introduce an architectural limitation: head-of-line blocking. If an error requires a 30-second delay before retrying, holding the consumer thread on that record halts consumption for every subsequent message on the partition.
If thousands of messages per second arrive on that partition, a 30-second pause creates substantial consumer lag. Furthermore, retrying across extended delays risks exceeding max.poll.interval.ms, which triggers partition rebalance storms.
To resolve this limitation, modern enterprise architectures use non-blocking retries using a ladder of dedicated delay topics.
01The concept of non-blocking retries
In a non-blocking retry architecture, a failing record is published forward to an intermediate retry topic. The consumer on the primary topic commits the failed record's offset immediately and continues processing healthy downstream records at wire speed.
Main Topic: orders
[Msg 101] ➔ Processed
[Msg 102] ➔ Fails (Forwarded to orders-retry-1000) ➔ Committed!
[Msg 103] ➔ Processed immediately (No waiting)
Retry Topic 1: orders-retry-1000 (1-second delay)
[Msg 102] ➔ Pauses until 1s elapsed ➔ Retries ➔ Fails (Forwarded to orders-retry-5000)
Retry Topic 2: orders-retry-5000 (5-second delay)
[Msg 102] ➔ Pauses until 5s elapsed ➔ Retries ➔ Fails (Forwarded to orders-dlt)
Dead-Letter Topic: orders-dlt
[Msg 102] ➔ Quarantined permanently for inspectionThe architectural trade-off: message ordering
Non-blocking retries trade strict global partition ordering for continuous high throughput.
If order message 102 fails and is routed to a retry topic, message 103 on the same partition will be processed before message 102 finishes its retries. For independent business entities (such as distinct customer shopping carts or separate sensor readings), this reordering is acceptable. However, for strictly sequential entities (such as financial ledger debits followed by credits on the same account), blocking retries or partitioned sequential retries remain necessary.
Loading the rest of the lesson…