Message Broker
Introduction
A message broker is software that facilitates the exchange of messages between applications, systems, and services. It allows linked systems to communicate directly, even if they’re built using different technologies, deployed on separate platforms, or use distinct messaging protocols.
Message brokers promote async communications among services so that the sending app doesn’t have to wait for the receiving app's response. This improves fault tolerance and resiliency in the infrastructure.
Message brokers increase the flexibility to scale the applications
Terminology
Producer
A service that responsible for transmitting messages. It's linked to the message broker, also known as publishers in the publish/subscribe model.
Consumer
A service that receives messages waiting in the message broker. They’re known as subscribers in the publish-subscribe pattern.
Topic / Queue
Store the messages and send the messages with first-in first-out principle to consumer when consumer is active
Exchanger
a logical structure or an object that resides on queues and directs the message broker to form a group where consumers or producers can create or listen to send or receive messages.
Flow
Point-to-Point messaging model
Producer and Consumer have one-to-one relationship
Producer can send multiple messages to queues
Only one consumer can receive the message from the queue
Publish/Subscribe messaging model
A publisher can publish multiple topics
Topic can be published by multiple publisher and received by multiple subscriber
A subscriber can subscribe multiple topics
Message Broker vs RESTful API
HTTP is a request-response protocol, it’s best used in synchronous communication, so the response must be waited before taking next action
Message brokers provide asynchronous communication between services. This means the producer doesn’t have to wait for a response from the receiving service. This increases the fault tolerance and robustness of systems.
Tools
RabbitMq
GCP Pub/Sub
Kafka
References
Last updated
Was this helpful?