# RabbitMQ — Reliable Open-Source Message Broker > RabbitMQ is one of the most popular open-source message brokers, implementing AMQP, MQTT, STOMP, and more. Used by thousands of companies for reliable async messaging, RPC, pub/sub, task queues, and microservice communication. ## Install Save the content below to `.claude/skills/` or append to your `CLAUDE.md`: ## Quick Use ```bash # Docker docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 \ -e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin \ rabbitmq:3-management # UI at http://localhost:15672 ``` Python producer (pika): ```python import pika conn = pika.BlockingConnection(pika.ConnectionParameters("localhost")) channel = conn.channel() channel.queue_declare(queue="tasks", durable=True) channel.basic_publish( exchange="", routing_key="tasks", body="process order 42", properties=pika.BasicProperties(delivery_mode=2), # persistent ) conn.close() ``` Python consumer: ```python def callback(ch, method, properties, body): print(f"Received {body}") ch.basic_ack(delivery_tag=method.delivery_tag) channel.basic_qos(prefetch_count=1) channel.basic_consume(queue="tasks", on_message_callback=callback) channel.start_consuming() ``` ## Intro RabbitMQ is one of the most popular and mature open-source message brokers. Originally built on Erlang/OTP (still its core), it implements the Advanced Message Queuing Protocol (AMQP) and supports MQTT, STOMP, HTTP, WebSocket. Used by thousands of companies for reliable async messaging, task queues, pub/sub, and microservice communication. - **Repo**: https://github.com/rabbitmq/rabbitmq-server - **Stars**: 13K+ - **Language**: Erlang - **License**: MPL 2.0 ## What RabbitMQ Does - **AMQP 0.9.1** — primary protocol, plus AMQP 1.0 - **Exchanges** — direct, fanout, topic, headers - **Queues** — classic, quorum (Raft-based), streams (append-only log) - **Bindings** — flexible routing rules - **Persistence** — durable exchanges/queues + persistent messages - **Clustering** — high availability across nodes - **Mirrored/Quorum queues** — HA with replication - **Plugins** — MQTT, STOMP, Federation, Shovel, Web STOMP - **Management UI** — http://host:15672 - **RabbitMQ Streams** — append-only log (Kafka-like) ## Architecture Erlang processes are cheap and fault-tolerant. A RabbitMQ node runs thousands of Erlang processes per queue/connection. Cluster nodes share metadata via Mnesia DB (or Khepri in newer versions). Messages route through exchanges by binding rules. ## Self-Hosting ```yaml # docker-compose.yml with clustering version: "3" services: rabbit1: image: rabbitmq:3-management hostname: rabbit1 environment: RABBITMQ_ERLANG_COOKIE: "secretcookie" rabbit2: image: rabbitmq:3-management hostname: rabbit2 depends_on: [rabbit1] environment: RABBITMQ_ERLANG_COOKIE: "secretcookie" ``` ## Key Features - AMQP, MQTT, STOMP protocols - Multiple exchange types - Quorum queues (Raft) - Streams (Kafka-like append log) - Federation across clusters - Shovel for cross-cluster forwarding - Management UI and HTTP API - Plugins ecosystem - TLS and SASL auth - Mature client libraries for every language ## Comparison | Broker | Protocol | Model | Best For | |---|---|---|---| | RabbitMQ | AMQP + more | Queues + exchanges | Task queues, RPC, flexible routing | | Kafka | Kafka | Distributed log | Event streaming, analytics | | NATS | NATS | Subject-based pub/sub | Low-latency microservice comms | | Redis Streams | Redis | Log + consumer groups | Lightweight streams | | ActiveMQ | AMQP + JMS | Queues + topics | Legacy Java systems | ## FAQ **Q: RabbitMQ vs Kafka?** A: RabbitMQ is a traditional MQ (flexible routing, task queues, RPC, low-latency async); Kafka is a distributed log (event streaming, long retention, high throughput). The choice depends on whether you need queue semantics or stream semantics. **Q: Classic vs Quorum queue?** A: Quorum is the new Raft-based HA queue type in v3.8+ and is recommended for production. Classic mirrored queues are deprecated after v3.12. **Q: How large does it scale?** A: A single node supports tens of thousands of connections and tens of thousands of messages per second. Clusters scale higher. For very high throughput (millions/sec), Kafka is recommended. ## Sources - Docs: https://www.rabbitmq.com/documentation.html - GitHub: https://github.com/rabbitmq/rabbitmq-server - License: MPL 2.0 --- Source: https://tokrepo.com/en/workflows/rabbitmq-reliable-open-source-message-broker-90136d3b Author: AI Open Source