Message Broker
A Message Broker is a software system that acts as an intermediary for exchanging messages between applications, services, or systems. It is a core component of Message-Oriented Middleware (MOM) and is responsible for receiving, routing, storing, and delivering messages.
A message broker is an architectural pattern for message validation, message transformation and message routing. It mediates communication amongst applications, minimizing the mutual awareness that applications should have of each other in order to be able to exchange messages, effectively implementing decoupling.
The purpose of a broker is to take incoming messages from applications and perform some action on them.
Actions of a Message Broker
The following are examples of actions that might be taken in the broker:
• Route messages to one or more of many destinations
• Transform messages to an alternative representation
• Perform message aggregation, decomposing messages into multiple messages and sending them to their destination, then recomposing the responses into one message to return to the user
• Interact with an external repository to augment a message or store it
• Invoke Web services to retrieve data
• Respond to events or errors
• Provide content and topic-based message routing using the publish–subscribe pattern.
Key Components of Message Broker
1. Producer
Sends messages
Doesn’t need to know who will consume them
2. Message Broker
Examples:
• Apache ActiveMQ
• RabbitMQ
• Apache Kafka
• IBM MQ
Responsibilities:
• Message routing
• Load balancing
• Persistence (optional storage)
• Delivery guarantees
3. Consumer
Receives and processes messages
Can be offline when message is sent
4. Message
Contains:
• Payload (data: JSON, XML, text, binary)
• Metadata (headers, priority, timestamps)
Messaging Patterns
1. Queue (Point-to-Point)
One producer → one consumer
Message is consumed once
Example: Order processing system
2. Topic (Publish/Subscribe)
One producer → many consumers
Each subscriber gets a copy
Example:
• News updates
• Stock market alerts
Key Features of a Message Broker
1. Asynchronous communication
Systems communicate without waiting for responses.
2. Loose coupling
Services are independent of each other.
3. Message persistence
Messages are stored until delivered (if configured).
4. Load balancing
Distributes messages across multiple consumers.
5. Reliability guarantees
Supports:
• Acknowledgements
• Retries
• Dead-letter queues
6. Protocol support
Common protocols include: