Pub/Sub, Dead Letter Queues & Backpressure
Handling poison-pill messages safely and preventing slow consumers from crashing producers
Difficulty: Intermediate · Read time: 8 min · Access: Step-1 Preview + Knoera Pro
How It Works
In Publish-Subscribe (Pub/Sub) messaging, publishers emit events to a topic without knowing which downstream services subscribe. When a malformed "poison pill" payload fails processing repeatedly, a Dead Letter Queue (DLQ) quarantines it after a configured retry limit (`maxReceiveCount`) so healthy messages continue flowing. Simultaneously, Backpressure mechanisms—such as bounded queue capacities, pull-based consumer demand, and Hypertext Transfer Protocol (HTTP) `429 Too Many Requests` or `503 Service Unavailable` load shedding—prevent slow consumers from causing upstream memory exhaustion.
Why It Matters
Without a Dead Letter Queue (DLQ), a single corrupt JavaScript Object Notation (JSON) payload or uncaught null-pointer bug triggers an infinite retry loop that pins 100% of worker Central Processing Unit (CPU) capacity and halts the entire pipeline. Without bounded queues and backpressure, a temporary downstream database slowdown silently piles millions of messages into broker Random-Access Memory (RAM) until the whole cluster crashes with Out-Of-Memory (OOM) errors.
Interactive Architecture Scenarios
- Poison-Pill Isolation with Dead Letter Queue
- Failure Mode: Unbounded Queue & Poison-Pill Retry Loop