RabbitMQ Queue Max-Length & Overflow Behavior Design Prompt
Design bounded RabbitMQ queues with max-length / max-length-bytes limits and the right overflow behavior (drop-head, reject-publish, or reject-publish-dlx) so a slow consumer never exhausts broker memory or disk.
- Target user
- Backend and platform engineers designing bounded RabbitMQ queues
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT, Cursor
The prompt
You are a senior RabbitMQ engineer who designs bounded queues so that a slow or dead consumer causes controlled backpressure or dead-lettering instead of an unbounded backlog that trips the memory or disk alarm. Help me pick the right limits and overflow behavior for my queue. I will provide: - The queue's role: what messages it carries, whether every message must be processed or newest-wins is acceptable, and the business cost of dropping one [DESCRIBE] - Traffic shape: steady vs bursty publish rate, normal consumer throughput, and worst-case consumer outage duration [DESCRIBE] - Message size: average and max body bytes [DESCRIBE] - Current setup: queue type (quorum/classic/stream), existing policies, and whether a dead-letter exchange already exists [PASTE OR DESCRIBE] Your job: 1. **Decide whether to bound the queue at all** — explain that an unbounded queue turns a consumer outage into a broker-wide resource alarm that blocks every publisher, and that a length or byte limit converts that into a local, predictable failure. Recommend bounding any queue whose consumer can fall behind. 2. **Pick the limit dimension** — `x-max-length` (message count) vs `x-max-length-bytes` (total body bytes). Recommend byte limits when message sizes vary widely, count limits when they're uniform, and note you can set both. Size the limit from the max consumer-outage window times publish rate, with headroom below the memory watermark. 3. **Choose overflow behavior** — the three modes and their consequences: `drop-head` (discard oldest, silent data loss, newest-wins semantics), `reject-publish` (basic.nack to publishers using confirms, backpressure propagates to the sender), and `reject-publish-dlx` (nack plus dead-letter the rejected message). Map each to my must-not-drop requirement and confirm-mode support. 4. **Wire dead-lettering if needed** — when to pair the limit with a dead-letter exchange and DLQ so rejected/overflowed messages are captured for replay rather than lost, and how that interacts with each overflow mode. 5. **Prefer policy over queue args** — recommend applying limits via a `set_policy` pattern rather than per-queue `x-arguments`, so limits are operable and changeable without redeclaring queues, and warn that the policy applies retroactively to matching queues that already hold a backlog. 6. **Verify and alert** — how to confirm the effective limit with `list_queues`, and the metrics to alert on (queue depth approaching the limit, publish nacks, dead-letter rate) so overflow is visible. Output as: (a) recommended limit dimension and value with the sizing math, (b) the overflow mode and why it fits my must-not-drop requirement, (c) the exact `rabbitmqctl set_policy` command and any DLX/DLQ wiring, and (d) the metrics to alert on. If my requirements are contradictory (e.g. must-not-drop plus a hard length cap and no DLQ), say so and force the trade-off. Never recommend `drop-head` for a queue where dropping a message has real cost. Show the policy as a command to review before applying, and always include the "this is retroactive" caveat when a backlog may already exist.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Why this prompt works
Most RabbitMQ outages that look like “the broker ran out of memory” are really one unbounded queue absorbing a consumer outage until the high-watermark alarm blocks every publisher cluster-wide. This prompt reframes the problem as a design choice: bound the queue so a stuck consumer produces a local, predictable failure instead of a global backpressure event. Starting from the business cost of dropping a message, it drives toward the one decision people get wrong — overflow behavior — before touching numbers.
The core of the prompt is making the three overflow modes concrete and consequential. drop-head is the default and silently deletes the oldest messages, which is fine for a newest-wins metrics feed and catastrophic for an orders queue; reject-publish propagates backpressure to publishers using confirms; and reject-publish-dlx captures rejected messages for replay. By tying each mode to the must-not-drop requirement and to publisher-confirm support, the prompt prevents the common mistake of accepting silent data loss without realizing it.
It’s also operationally honest. Recommending policies over per-queue arguments keeps limits changeable without redeclaring queues, and the repeated “this is retroactive” guardrail stops the classic incident where applying a small max-length to a queue that already holds a large backlog instantly drops or dead-letters the excess. The result is a bounded-queue design you can apply deliberately, with the dead-letter wiring and alerts that make overflow observable rather than a surprise.
Related prompts
-
RabbitMQ Message TTL & Expiration Strategy Prompt
Decide where and how to apply message TTL, queue TTL, and max-length so stale messages expire safely instead of piling up or silently disappearing.
-
RabbitMQ Queue Backpressure & Flow-Control Triage Prompt
Diagnose why a RabbitMQ queue is backing up and producers are being throttled, and decide whether the bottleneck is slow consumers, flow control, or a resource alarm.
-
RabbitMQ Blue-Green Cluster Migration Plan Prompt
Plan a blue-green migration to a brand-new RabbitMQ cluster using Shovel to drain in-flight messages, cut clients over vhost-by-vhost, and keep a clean rollback path.
-
RabbitMQ Classic Queue v2 (CQv2) Storage Migration Design Prompt
Plan a safe migration of classic queues to the CQv2 message store to cut memory use and improve consistency, validating version support, feature flags, and per-queue conversion.
More RabbitMQ prompts & error guides
Browse every RabbitMQ prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.