What is Message broker
Simply says it is an intermediator and exchanging the messages between the client and the server.
Developer community faces a problem to exchange messages(millions , tons of message). To make it simple and reliable, message broker steps in. Earlier we use simple end points for machine to machine communication. But nowadays we have special message brokers. They can validate, store, route, translate and deliver messages to the right destinations. It is a discrete service. So the producers and consumers communicate with it using standard protocols.
Message broker relies on message queue in order to provide reliable message storage and guaranteed delivery. In that messages are stored in the exact order and will remain in the queue until receipt is confirmed.
Eg. Number of registrations in any system. When a task sends data to several applications and avoiding to use their API directly, When you want to complete processes in an order-We use message broker
Message Broker uses 2 models for communication:
- Publish and Subscribe (Topics) :- In this model producer is called publisher and consumer is called subscriber. Producers send messages on a topic. One or many producers can publish same topic, and one or more messages from the same topic can be received by many subscribers. Consumers subscribe to topics, and all messages published to the topic are received by all subscribers on the topic.
- Point-to-Point (Queues) :- In this model only one producer and one consumer. It uses a queue to store messages that has sent by the producer until received by the consumer. Producer sends message to the queue and consumer retrieves that from the queue and sends acknowledgment. Multiple receivers may listen on a queue, but each message in the queue may only be consumed by one of the queue’s receivers.
Apart from this, there are some Server based Message Brokers, they use different options for messaging. Each designed to address a different use cases:
- Apache Kafka
- Apache Pulsar
- Amazon Web Services (AWS) Amazon MQ
- Amazon Web Services (AWS) Kinesis
- Apache ActiveMQ
- Apache Qpid
I hope you got a basic understanding of message broker. Hope to cover server based message brokers in upcoming articles.