What are Message Brokers and Why do we need them?

dilshan ukwattage
4 min readMay 16, 2021

--

What are Message Brokers

Message brokers are inter application communication technology that allows applications, systems, and services to communicate with each other and exchange information.This is accomplished by the message broker converting messages between structured messaging protocols. This enables interdependent services to communicate directly with one another, even though they are written in separate languages or run on different platforms.Message brokers are software modules that are used in messaging middleware, or message-oriented middleware (MOM) solutions. This type of middleware allows developers to focus on the application’s core logic by providing a clear way to manage data flow between application components.

Why we need message brokers

Software developers are confronted with the issue of efficient data sharing as a result of this digitization. Assume you’ve created your own app. It’s an online store, for example. So, you’re still working in your technical scope, and one day you’ll need to integrate your software with other applications.
Previously, you would use simple “end points” for machine to machine communication. However, special message brokers are now available on these days. They make data transfer easy and safe. The message format is determined by a variety of protocols used by these methods. The protocols describe how a message should be sent, stored, and consumed.

When to use Message brokers

  • If you want to control data feeds. For example, the number of registrations in any system.
  • When the task is to send data to several applications and avoid direct use of their API.
  • When you need to complete processes in a defined order, like a transactional system.

So, we can say that message brokers can do four important things:

  1. divide the publisher and consumer.
  2. store the messages.
  3. route messages.
  4. check and organize messages.

Message broker models

Message brokers offer two basic message distribution patterns or messaging styles:

  1. Point to Point messaging(Queues)
  2. Publish and Subscribe (Topics)

Point to point messaging(Queues)

In simply Point-to-point communications has one producer and on consumer. This style of messaging typically uses a queue to store messages sent by the producer until they are received by the consumer. The message producer sends the message to the queue, and the message recipient retrieves messages from the queue and sends acknowledgment that the message was received. Messages can be sent to the same queue by multiple producers, and messages can be retrieved from the same queue by multiple consumers. As several consumers are used, each receives a portion of the message stream, allowing for parallel processing.

Publish and Subscribe (Topics)

When it’s come to the publish and subscribe model each message is published to a topic by the message producer, and multiple message consumers subscribe to the topics from which they want to receive messages. All messages posted to a subject are sent to all consumers that have subscribed to it. This is like youtube subscribe. When we subscribe a channel in youtube we will get an notification when that channel has put a new video.This is a broadcast-style delivery system in which the message’s publisher and customers have a one to many relationship.

In modern world there are many message brokers. Some of them are RabbitMQ, Kafka(By Apache), Redis, SQS(By Amazon).

RabbitMQ

RabbitMQ is an open-source message-broker software that written in Erlang programming language. It originally implemented the Advanced Message Queuing Protocol (AMQP) and has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol (STOMP), MQ Telemetry Transport (MQTT), and other protocols.

Kafka

Apache Kafka is a framework implementation of a software bus using stream-processing. It is an open-source software platform developed by the Apache Software Foundation written in Scala and Java.

Java Messaging Service (JMS)

JMS supports both messaging models: point-to-point (queuing) and publish-subscribe. JMS was defined to allow Java application to use enterprise messaging systems. More importantly, it provides a common way for Java applications to access such enterprise messaging systems.

So I hope this blog will give you a basic idea of message broker. If you need any clarifications check down the below references links.

References

--

--

dilshan ukwattage
dilshan ukwattage

Written by dilshan ukwattage

Software Engineer at IFS R&D International (Pvt) Ltd

Responses (1)