Publish messages to RabbitMQ reliably using publisher confirms and configure consumers with prefetch and a dead-letter exchange

domain: rabbitmq · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Enable publisher confirms on the channel by calling channel.confirmSelect() (AMQP confirm.select); after this, every published message is assigned a delivery tag and the broker sends a basic.ack or basic.nack confirming persistence to disk (if the queue and message are durable)
  2. Publish messages with delivery_mode=2 (persistent) and ensure both the exchange and queue are declared as durable=True; messages to non-durable queues or exchanges will not survive a broker restart even with publisher confirms enabled
  3. For consumers, set the channel prefetch count (basic.qos with prefetch_count) before starting consumption; a prefetch of 1 ensures a consumer only holds one unacknowledged message at a time (fair dispatch), while higher values improve throughput at the cost of uneven distribution
  4. Acknowledge messages manually (basic.ack with the delivery tag) after successful processing; use basic.nack with requeue=False to reject a message without requeueing (sends it to the dead-letter exchange if configured)
  5. Configure a dead-letter exchange (DLX) on the queue by setting the x-dead-letter-exchange argument at queue declaration time; bind a separate queue to the DLX to receive rejected or expired messages for inspection and reprocessing
  6. Set x-message-ttl on the queue or per-message to expire unprocessed messages after a timeout; expired messages are routed to the DLX just like nacked messages

Known gotchas

Related routes

Configure RabbitMQ dead-letter exchanges for failed messages
rabbitmq.com · 5 steps · unrated
configure rabbitmq memory and disk alarms to prevent publisher-induced outages
rabbitmq.com · 5 steps · unrated
Schedule delayed message delivery in RabbitMQ using the delayed message exchange plugin
rabbitmq.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans