Tutorials Microservices Mastery
Message Brokers: Introduction to RabbitMQ & Azure Service Bus
On this page
Message Brokers 101
A Message Broker is the "Post Office" of your system. Instead of Service A talking directly to Service B, Service A leaves a "Letter" (Message) in a mailbox. The broker ensures the message is delivered, even if the destination service is currently sleeping or busy.
1. RabbitMQ (The Developer's Choice)
RabbitMQ is an open-source broker that is perfect for complex routing (Exchanges and Queues). It is lightweight, fast, and runs perfectly in a Docker container for local development.
2. Azure Service Bus (The Enterprise Choice)
Service Bus is a cloud-managed broker. It is 100% serverless, meaning you don't have to manage servers. It includes built-in support for **Scheduled Messages**, **Sessions**, and **Duplicate Detection**.
3. Queues vs Topics
- Queue: Point-to-Point. One message goes to ONE consumer. Perfect for "Tasks" (e.g., 'Process this invoice').
- Topic: Publish/Subscribe. One message goes to EVERYONE who is interested. Perfect for "Notifications" (e.g., 'User has logged in').
4. Interview Mastery
Q: "What is At-Least-Once Delivery, and why does it matter?"
Architect Answer: "Most brokers guarantee 'At-Least-Once' delivery. This means the broker will keep trying to send the message until it receives an ACK (Acknowledgement). However, in rare network failures, a message might be delivered twice. This is why your consumer code MUST be **Idempotent**. You should always check if you've already processed a specific MessageId before performing any database updates."