100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace
Software Architecture

Message Brokers in Microservices

Learn how message brokers like RabbitMQ and Kafka durably deliver messages between services, the difference between queues and topics, and delivery guarantees.

CommunicationIntermediate10 min readJul 10, 2026
Analogies

The Infrastructure Behind Asynchronous Messaging

A message broker is the piece of infrastructure that sits between producers and consumers, durably storing messages and guaranteeing delivery even if the consumer is temporarily offline, which is what actually makes asynchronous and event-driven communication reliable in practice. Without a broker, a producer sending a message directly to a consumer would lose that message entirely if the consumer happened to be down at that exact moment; with a broker, the message persists on disk until a consumer is ready to process it. Popular brokers include RabbitMQ, built around the AMQP protocol with flexible routing (queues, exchanges, and bindings), and Apache Kafka, built around durable, partitioned, replayable event logs.

🏏

Cricket analogy: A message broker durably holding messages is like a cricket ground's official archive keeping every ball's data recorded even if the live broadcast feed briefly cuts out, so nothing is lost when the feed resumes.

Queues vs Topics: Point-to-Point and Publish-Subscribe

Brokers typically support two delivery models. In point-to-point queueing, each message is delivered to exactly one consumer among a competing pool, which is ideal for distributing work like processing image uploads across a worker pool, since you want each job done once, not duplicated. In publish-subscribe (topics), each message is delivered to every subscriber independently, which is the natural fit for the event-driven broadcast pattern where an OrderPlaced event needs to reach the shipping, loyalty, and analytics services simultaneously. RabbitMQ exposes both via exchanges bound to queues, while Kafka's topics with consumer groups let you achieve both patterns depending on whether consumers share a group.

🏏

Cricket analogy: Point-to-point queueing is like a single bowler in the attack getting exactly one over to bowl, not shared with anyone else, while publish-subscribe is like the entire stadium PA broadcasting the same six-hit replay to every single spectator simultaneously.

Delivery Guarantees and Ordering

Brokers offer different delivery guarantees — at-most-once (fire and forget, messages can be lost), at-least-once (messages are redelivered until acknowledged, but duplicates are possible), and exactly-once (harder to achieve, usually implemented via idempotent consumers plus at-least-once delivery rather than a true broker-level guarantee). Most production systems choose at-least-once delivery and design consumers to be idempotent, safely processing the same message twice without side effects, since true exactly-once semantics across a network are extremely difficult to guarantee. Kafka additionally guarantees ordering within a partition but not across partitions, so choosing a sensible partition key (like customerId) matters when order matters for a given entity.

🏏

Cricket analogy: At-least-once delivery with possible duplicates is like a stadium replaying a controversial six on the big screen twice due to a technical hiccup; fans see it twice, but no one mistakes it for two actual sixes because they recognize the replay.

yaml
# Example: RabbitMQ topology for order events (declarative config)
exchanges:
  - name: orders.events
    type: topic

queues:
  - name: shipping.order-placed
    bind_to: orders.events
    routing_key: "order.placed"
  - name: loyalty.order-placed
    bind_to: orders.events
    routing_key: "order.placed"
  - name: image-processing.jobs   # point-to-point work queue
    consumers: 5                  # competing consumers share the load

A message broker is a stateful, critical piece of infrastructure — if it goes down or its disk fills up, every asynchronous and event-driven flow in the system stalls. Brokers must be run with replication, monitored disk capacity, and dead-letter queues configured so poison messages (ones that repeatedly fail processing) don't block the queue forever.

Dead-letter queues (DLQs) capture messages that fail processing after a configured number of retries, moving them out of the main queue so they don't block healthy messages, while giving engineers a place to inspect and manually reprocess failures.

  • A message broker durably stores messages between producer and consumer, making asynchronous communication reliable even when a consumer is temporarily down.
  • RabbitMQ (AMQP, flexible exchange/queue routing) and Kafka (durable, partitioned, replayable log) are the two most common broker choices.
  • Point-to-point queues deliver each message to exactly one consumer in a competing pool; publish-subscribe topics deliver each message to every subscriber.
  • Most production systems use at-least-once delivery combined with idempotent consumers rather than attempting true exactly-once semantics.
  • Kafka guarantees ordering within a partition but not across partitions, so partition key choice matters for order-sensitive entities.
  • Dead-letter queues capture repeatedly failing messages so they don't block the healthy flow of the main queue.
  • Because brokers are critical, stateful infrastructure, they need replication, disk monitoring, and alerting to avoid becoming a single point of failure.

Practice what you learned

Was this page helpful?

Topics covered

#SoftwareArchitecture#MicroservicesStudyNotes#SoftwareEngineering#MessageBrokersInMicroservices#Message#Brokers#Microservices#Infrastructure#StudyNotes#SkillVeris