What is RabbitMQ?
- Open-source message broker
- Acts as a middleman between services to send/receive messages
- Supports multiple messaging protocols, mainly AMQP
- Ensures asynchronous communication, reliability, and message persistence
What is AMQP?
- Advanced Message Queuing Protocol
- Standard protocol for messaging systems
- Defines how messages are formatted, sent, stored, and received
- Key components:
- Producer → Sends messages
- Exchange → Routes messages
- Queue → Stores messages
- Consumer → Receives messages
Four Exchange Types of AMQP
- Direct Exchange
- Routes messages to queues with matching routing keys
- Example:
"order.created"
→ goes only to order processing queue
- Fanout Exchange
- Sends messages to all bound queues, ignoring routing keys
- Example: Sending a system-wide notification
- Topic Exchange
- Routes messages based on pattern matching in routing keys
- Example:
"order.*"
matches "order.created"
, "order.cancelled"
- Headers Exchange
- Routes messages based on header attributes instead of routing keys
- Example: Send message only if
"type=pdf"
RabbitMQ Setup
Deploy RabbitMQ with Docker Compose