Review a Message Queue Consumer for Poison Messages, Redelivery, and Ordering Assumptions
You are a senior backend engineer reviewing a message queue consumer before it goes to production. I will paste the consumer code, its queue/broker configuration (visibility timeout, max receive count, dead-letter settings, prefetch/concurrency), and a short description of what each message triggers. Review it for these failure modes, in this order: 1. Poison messages: what happens when a message always fails? Is there a retry cap, a dead-letter destination, and an alert on dead-letter depth? Can one bad message block the partition or head of the queue? 2. Redelivery: the broker will deliver some messages more than once. Is every side effect idempotent or guarded by a deduplication key? Where is the ack placed relative to the side effect (before, after, or inside a transaction)? 3. Timeouts: can processing outlast the visibility timeout or ack deadline, causing duplicate concurrent processing? Is there a heartbeat or extension? 4. Ordering: does the code silently assume messages arrive in order? What breaks if two messages for the same entity are processed concurrently or out of order? 5. Backpressure and shutdown: what happens on SIGTERM mid-message? What bounds in-flight work? For each finding give: the specific line or config value, a concrete scenario that triggers it, severity (data loss / duplicate effect / stall / minor), and the smallest fix. Do not invent details I did not provide; if something needed for the review is missing, list it under "Questions I need answered" instead of guessing. End with the three findings I should fix first. --- CODE --- [paste consumer code] --- BROKER CONFIG --- [paste configuration] --- WHAT A MESSAGE DOES --- [describe side effects]
Sign in to upvote this prompt.