Negative Acknowledgments and Redelivery
You'll learn how consumers signal processing failures and how brokers control retry behavior to prevent message loss.
Core Idea
When a consumer successfully processes a message, it sends an acknowledgment (ACK). But what happens when processing fails—a database is down, validation fails, or the service crashes? The consumer needs a way to signal "I couldn't handle this message; please give it back to me or someone else." This is a negative acknowledgment (NACK or reject).
How NACKs Work
Instead of simply not acknowledging (which could indicate a crash), the consumer explicitly tells the broker: "I received this message but cannot process it." The broker then decides what to do based on its redelivery policy:
- Immediate requeue: Put the message back at the front of the queue
- Delayed retry: Wait before making it available again (backoff strategy)
- Redeliver to different consumer: Let another instance try
- Dead letter queue: After N failures, route to a special queue for investigation
Think of it like returning a package to the post office with "cannot deliver" instead of just ignoring the doorbell—you're actively communicating the problem so the system can respond appropriately.
Redelivery Controls
Most brokers let you configure:
- Max retry count: How many times to attempt redelivery
- Backoff intervals: Exponential delays between retries (1s, 2s, 4s...)
- Dead letter destination: Where permanently failed messages go
- Redelivery headers: Metadata tracking attempt count and timestamps
These controls prevent infinite retry loops while giving transient failures a chance to resolve.
Key Takeaway:
Negative acknowledgments let consumers explicitly signal processing failures, triggering broker-controlled redelivery policies with retry limits and dead letter routing to handle persistent failures gracefully.