What does a message broker (Kafka, RabbitMQ) do?
A message broker is a component that passes messages between services in a distributed system, making their interaction asynchronous and reliable.
The main idea
Services do not call each other directly, but exchange messages through a broker:
- one service publishes an event ("Payment completed"),
- another subscribes to such events and reacts ("Create a delivery record").
This removes rigid dependencies between services.
What a message broker does
- Accepts and stores messages acts as a buffer between publishers and consumers.
- Delivers messages guarantees delivery even when the recipient is temporarily unavailable.
- Routes streams sends the message to the right queue or topic.
- Supports scaling distributes the load among several subscribers.
- Ensures reliability and order stores acknowledgments, redelivers lost messages, and preserves the order of events.
Message broker examples
- RabbitMQ: a classic queue broker (the AMQP protocol), great for business events and processing tasks.
- Apache Kafka: a high-performance streaming platform for data streams and event logs.
Summary:
A message broker is the "mail carrier" between microservices: it accepts, stores, and delivers messages, providing asynchrony, resilience, and loose coupling between parts of the system.
Short Answer
Interview readyPremium
A concise answer to help you respond confidently on this topic during an interview.