Andrew Mercer
on this page

RabbitMQ Lab

Hands-on companion to the RabbitMQ overview and lab guide. Targets RabbitMQ 4.3.

Quick start

make env          # .env with random credentials and Erlang cookie
make up           # single node, waits until healthy
make venv         # Python virtualenv with pika
make creds        # show the generated login for http://localhost:15672

source .venv/bin/activate
cd py
python basics.py consume      # terminal 1
python basics.py produce      # terminal 2

Requirements: Docker with Compose v2, Python 3.10+, openssl, jq (health check only), make.

Layout

.
├── compose.yaml              single node (+ --profile monitoring)
├── compose.cluster.yaml      3 nodes behind HAProxy (+ --profile monitoring)
├── config/
│   ├── rabbitmq.conf         shared broker settings  -> conf.d/20-lab.conf
│   ├── cluster/rabbitmq.conf peer discovery          -> conf.d/30-cluster.conf
│   ├── enabled_plugins       management + prometheus
│   ├── haproxy.cfg
│   ├── prometheus/           scrape configs + alert rules
│   └── grafana/provisioning/ Prometheus datasource
├── py/                       one script per exercise, each with --help
└── scripts/
    ├── healthcheck.sh        Nagios-style API health check
    ├── triage.sh             read-only troubleshooting sweep
    └── perftest.sh           PerfTest benchmark scenarios
Script Lab Topic
basics.py 2.1 topic exchange, quorum queue, confirms, manual acks
work_queue.py 2.2 competing consumers, prefetch and fair dispatch
pubsub.py 2.3 fanout, exclusive server-named queues
slow_worker.py 2.4 long jobs, heartbeats, thread-safe acks, consumer timeouts
retry.py 3.1 poison messages, delivery limit, DLX, 4.3 delayed retry
delayed.py 3.2 scheduled delivery with TTL tiers
priority.py 3.3 quorum vs classic priorities
rpc.py 3.4 request/reply with Direct Reply-to
streams.py 3.5 streams and offset replay
confirms.py 5.2 the cost of publisher confirms
failover.py 6.3 node failure, at-least-once delivery, duplicates
orders.py 7 event-driven pipeline with compensation

Stacks

Only run one stack at a time; both bind the same host ports (all on 127.0.0.1).

Single (make up) Cluster (make cluster-up)
AMQP localhost:5672 localhost:5672 (HAProxy)
Management http://localhost:15672 http://localhost:15672 (HAProxy)
Prometheus http://localhost:9090 http://localhost:9090
Grafana http://localhost:3000 http://localhost:3000
HAProxy stats http://localhost:8404

make clean removes both stacks and their volumes.

Not production

Credentials and the Erlang cookie live in .env and are passed as environment variables, TLS is off, and the monitoring images float on latest. The overview's production checklist covers what changes for real deployments.