{
  "id": 15567661,
  "title": "Replay only some RabbitMQ dead letters: by exception, header or routing key",
  "url": "https://urgent.news/2026/10/19/replay-only-some-rabbitmq-dead-letters-by-exception-header-or-routing",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-10-19T05:58:30.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/viktorbaumann/replay-only-some-rabbitmq-dead-letters-by-exception-header-or-routing-key-3goa"
  },
  "original_language": "en",
  "account": "On a single day, the tax service went down for twenty minutes. Upon its return, the orders.dlq queue contained 230 messages. Out of these messages, 41 were due to TaxServiceUnavailableException, while the rest were missing orders and declined payments that a replay would reprocess. Unfortunately, RabbitMQ lacks the ability to move messages based on message headers. The queue hands out messages sequentially from its head, and the management UI provides move messages and shovel functionalities that process all messages.\n\nHere's how to selectively replay only the 41 messages with delivery tags 1 through 41, using RabbitMQ 4.3.6 with both classic and quorum queues. The provided script demonstrates the process.\n\nThe first attempt using basic_get with auto_ack set to False would lead to an endless loop. The script attempts to process each message, checks if it meets the criteria, and then either requeues the message with nack (not acknowledged) or publishes it to the work queue. To avoid requeuing messages, the script must keep the skipped messages unacknowledged while iterating through the queue. Once the iteration is complete, a single basic_nack call with multiple set to true releases all the unacknowledged messages back to the dead-letter queue. The script prints the number of messages moved from the dead-letter queue to the work queue.",
  "summary": "Originally published at warrenops.io . The tax service was down for twenty minutes and is back. orders.dlq holds 230 messages: 41 of them failed with TaxServiceUnavailableException , the rest are missing orders and declined payments that a replay would only send round again. RabbitMQ has no \"move the messages where header X equals Y\": a queue hands out messages from the head, one after the other,…",
  "key_points": [
    "Tax service outage lasted 20 minutes, causing 230 messages in orders.dlq queue",
    "RabbitMQ cannot move messages based on headers, limiting selective replay",
    "Script selectively replays 41 messages with delivery tags 1-41, moving them to work queue"
  ],
  "editors_take": "Implementing selective message replay overcomes RabbitMQ's sequential processing limitations, allowing developers to recover specific failed orders without inadvertently reprocessing invalid or declined payment messages.",
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}