A poison pill is a message that repeatedly fails when a consumer tries to process it. Unlike a temporary network glitch, a malformed message will keep failing if retried, potentially trapping the consumer in an endless crash-and-redelivery loop. section 7.4.4 section 10.1
Keep the failure from holding up the rest of the system:
- Set a maximum number of delivery attempts. After that limit, move the message to a Dead Letter Queue (DLQ) for inspection and possible reprocessing. section 7.4.4
- Do not treat every failure the same: retries with backoff can help temporary glitches, while permanent faults such as corrupted payloads should fail fast or go to a DLQ. section 10.1
A message that keeps respawning
A shipping message with an Order ID of -1 triggers a logic exception. The broker redelivers it, the consumer crashes again, and repeated attempts can fill logs and consume CPU. A delivery limit can eject it to a DLQ so other messages keep flowing. section 7.4.4
"RetryPolicy": {
"MaxDeliveryCount": 5, // Try 5 times
"BackoffStrategy": "Exponential", // Wait longer each time (1s, 2s, 4s, 8s)
"DeadLetteringOnExpiration": true // If 5 fails, move to DLQ
}A sample retry policy shows a maximum delivery count, exponential backoff, and dead-lettering on expiration. section 7.4.4
