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.
What it is
RabbitMQ is one of the most widely deployed open-source message brokers. Built on Erlang/OTP, it implements the Advanced Message Queuing Protocol (AMQP) as its primary protocol and also supports MQTT, STOMP, HTTP, and WebSocket. It handles async messaging, task queues, pub/sub patterns, RPC, and microservice communication.
RabbitMQ suits backend teams that need reliable message delivery between services. It runs on Linux, macOS, and Windows, with official Docker images and Kubernetes operators available.
How it saves time or tokens
RabbitMQ decouples producers from consumers, letting services scale independently. Instead of polling or blocking on synchronous HTTP calls, services push messages to queues and move on. Failed consumers retry automatically with configurable dead-letter exchanges. This eliminates manual retry logic and reduces wasted compute on failed operations.
How to use
- Run RabbitMQ with Docker using the management plugin for the web UI.
- Connect a producer using the
pikalibrary (Python) or any AMQP client. - Connect a consumer that processes messages and acknowledges them.
docker run -d --name rabbitmq -p 5672:5672 -p 15672:15672 \
-e RABBITMQ_DEFAULT_USER=admin -e RABBITMQ_DEFAULT_PASS=admin \
rabbitmq:3-management
Example
A Python producer sending a persistent message to a durable queue:
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),
)
conn.close()
A consumer processing and acknowledging messages:
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()
Related on TokRepo
- AI Tools for DevOps — Infrastructure and operations tools for modern backends
- AI Tools for Self-Hosted — Self-hosted alternatives for common infrastructure
Common pitfalls
- Forgetting to set
durable=Trueon queues anddelivery_mode=2on messages means data loss on restart. - The default
guestuser only works from localhost. Remote connections need a new user created viarabbitmqctl add_user. - Unacknowledged messages accumulate in memory. Always set
prefetch_countto limit how many messages a consumer holds at once.
Frequently Asked Questions
RabbitMQ primarily implements AMQP 0.9.1 and also supports AMQP 1.0, MQTT (for IoT), STOMP (for text-based messaging), HTTP, and WebSocket. Each protocol is enabled through a plugin. AMQP is enabled by default.
RabbitMQ is a message broker focused on routing and delivery guarantees. Kafka is a distributed log optimized for high-throughput event streaming. Use RabbitMQ for task queues, RPC, and complex routing. Use Kafka for event sourcing, log aggregation, and stream processing.
Yes. A single RabbitMQ node handles tens of thousands of messages per second. Clustering and sharded queues scale horizontally. Quorum queues provide replication across nodes for durability without sacrificing throughput.
Yes. RabbitMQ is open source under the Mozilla Public License 2.0. It is free to run and self-host. VMware (Broadcom) offers commercial support and a managed cloud service called CloudAMQP for teams that prefer not to operate it themselves.
RabbitMQ provides official client libraries for Java, .NET, Erlang, and Go. Community-maintained clients exist for Python (pika), Node.js (amqplib), Ruby (bunny), PHP, Rust, and many others. Any AMQP-compliant library works.
Citations (3)
- RabbitMQ GitHub— RabbitMQ open-source message broker with 13K+ stars
- RabbitMQ Documentation— AMQP protocol specification and RabbitMQ implementation
- Erlang Official Site— Erlang/OTP foundation for RabbitMQ reliability
Related on TokRepo
Discussion
Related Assets
HumHub — Open-Source Enterprise Social Network
A flexible, open-source social networking platform built on Yii2 for creating private communities, intranets, and collaboration spaces within organizations.
Dolibarr — Open-Source ERP & CRM for Business Management
A modular open-source ERP and CRM application written in PHP for managing contacts, invoices, orders, inventory, accounting, and more from a single web interface.
PrestaShop — Open-Source PHP E-Commerce Platform
A widely adopted open-source e-commerce platform written in PHP with a rich module marketplace, multi-language support, and a strong European user base.