$120 tested Claude codes · real before/after data · Full tier $15 one-timebuy --sheet=15 →
$Free 40-page Claude guide — setup, 120 prompt codes, MCP servers, AI agents. download --free →
clskills.sh — terminal v2.4 — 2,347 skills indexed● online
[CL]Skills_
NetworkingintermediateNew

RabbitMQ Dead Letter

Share

Configure dead letter exchanges for failed message handling

Works with OpenClaude

You are a RabbitMQ infrastructure engineer. The user wants to configure dead letter exchanges (DLX) to automatically route failed messages to a separate queue for analysis and replay.

What to check first

  • Run rabbitmqctl status to verify RabbitMQ is running and accessible
  • Check that you have a working connection string or credentials (host, port, username, password)
  • Verify the primary queue name and confirm it doesn't already have DLX bindings you'll conflict with

Steps

  1. Declare the main queue with x-dead-letter-exchange argument pointing to your DLX name and optional x-dead-letter-routing-key for routing
  2. Declare the dead letter exchange (DLX) as a durable exchange with type direct or topic
  3. Declare the dead letter queue (DLQ) with appropriate TTL or message retention settings
  4. Bind the DLQ to the DLX using the specified routing key
  5. Set x-max-retries or message TTL on the main queue to define when messages move to DLX
  6. Configure message TTL on main queue with x-message-ttl (in milliseconds) so expired messages trigger DLX routing
  7. Test by publishing a message to the main queue and verify it moves to DLQ after TTL or rejection
  8. Implement a consumer on the DLQ for monitoring, logging, or manual replay of failed messages

Code

import pika
import json
from datetime import datetime

# RabbitMQ connection parameters
RABBITMQ_HOST = 'localhost'
RABBITMQ_PORT = 5672
RABBITMQ_USER = 'guest'
RABBITMQ_PASSWORD = 'guest'

# Queue and exchange names
PRIMARY_EXCHANGE = 'orders_exchange'
PRIMARY_QUEUE = 'orders_queue'
PRIMARY_ROUTING_KEY = 'order.*'

DLX_EXCHANGE = 'orders_dlx'
DLX_QUEUE = 'orders_dead_letter_queue'
DLX_ROUTING_KEY = 'order.dead_letter'

def setup_dead_letter_queues():
    """Configure primary queue with DLX and create dead letter queue"""
    
    credentials = pika.PlainCredentials(RABBITMQ_USER, RABBITMQ_PASSWORD)
    connection = pika.BlockingConnection(
        pika.ConnectionParameters(host=RABBITMQ_HOST, port=RABBITMQ_PORT, 
                                  credentials=credentials)
    )
    channel = connection.channel()
    
    # Declare primary exchange
    channel.exchange_declare(
        exchange=PRIMARY_EXCHANGE,
        exchange_type='topic',
        durable=True
    )
    
    # Declare primary queue with DLX configuration
    channel.queue_declare(
        queue=PRIMARY_QUEUE,
        durable=True,
        arguments={
            '

Note: this example was truncated in the source. See the GitHub repo for the latest full version.

Common Pitfalls

  • Treating this skill as a one-shot solution — most workflows need iteration and verification
  • Skipping the verification steps — you don't know it worked until you measure
  • Applying this skill without understanding the underlying problem — read the related docs first

When NOT to Use This Skill

  • When a simpler manual approach would take less than 10 minutes
  • On critical production systems without testing in staging first
  • When you don't have permission or authorization to make these changes

How to Verify It Worked

  • Run the verification steps documented above
  • Compare the output against your expected baseline
  • Check logs for any warnings or errors — silent failures are the worst kind

Production Considerations

  • Test in staging before deploying to production
  • Have a rollback plan — every change should be reversible
  • Monitor the affected systems for at least 24 hours after the change

Quick Info

CategoryNetworking
Difficultyintermediate
Version1.0.0
AuthorClaude Skills Hub
rabbitmqdead-lettererror-handling

Install command:

curl -o ~/.claude/skills/rabbitmq-dead-letter.md https://clskills.in/skills/networking/rabbitmq-dead-letter.md

Related Networking Skills

Other Claude Code skills in the same category — free to download.

Want a Networking skill personalized to YOUR project?

This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.