Messaging frameworks
Before going through the messaging framework, it is important to know why it is useful and what are the reasons to designed messaging frameworks 👇
In modern world software applications are being more complex and they need high availability of data. Not only these things consumers are expecting high performance in their systems developers are struggling to keep those properties in their applications. But it is not a simple task. Normally clients are using the HTTP requests or other alternative methods to communicate via the servers. So when accessing a huge volume of customers in same times and keeping the availability and integrity is a big problem in complex systems. It means developers cannot guarantee how much percentage of the requested messages are reached to the server and then response back. To overcome those challenges, there is a solution called “Message Broker”.
Message Broker ✉️
Definition: — A message broker is a piece of software, which enables services and applications to communicate with each other using messages. The message structure is formally defined and independent from the services that send them. This allows applications to share information with one another, even if they’re written in different programming languages!
It can be placed in between the client and server, then it provides scalable and robust producer-consumer architecture for different types of software applications.
Basic concepts in massage broker
- Producer: It is the application that responsible for sending a particular message. Those messages send from the producer are stored inside the message broker for further distribution.
- Consumer: It is the application that waiting for the message response from the message broker.
- Queue/topic: It is just like a storage system. In message broker it has a folder in a file system to store the messages. It follows FIFO(First In First Out) logic to execute the requests.
- Exchanger: It is a logical configuration or a entity in the top of the queues to manage message broker’s tasks by saying to create some sort of a group, and which a consumers/producers can write or listen to, to send/receive messages
In publisher/ subscribe pattern producer is known as the publishers
and the consumer is known as the subscribers
.
Message broker distribution patterns
- Point-to-point messaging
In this pattern there is an one-to-one relationship between the producer and the receiver of the message. One message is send or consumed by only onetime. This is very important in the time when needed to take some action from the someone only once.
- Publish/subscribe
In this pattern publisher sent a message to the topic/queue without considering the subscriber. It has one to many relationship. The message transfer to the queue is distributed among all the subscribers in the end-point of the particular queue. This is very important to share the same thing with different consumers. As an example implementing a notification mechanism can be categorized under this pattern. In this pattern, components are able to transmit events from one to another as they are loosely coupled with each others. In this pattern, we can create variety of patterns like attaching different consumers to one queue of grouping consumers to receive desirable types of messages.
Advantages of message broker 😄 👍
- It can works as asynchronous way and enhance the performance of the system. No waiting time and tasks/requested can be distributed into separate process. Therefore it is able to fasten up the general process and provide high performance systems
- Increase the reliability and availability of the messages. Message brokers have special characteristics called redelivering. So in the failure of consumer, message broker can send the message again in the same time or after few minutes. It has routing mechanism for handle not delivered messages and it is named as the dead-letter mechanism. Therefore it supports the systems to be high available and reliable
- Enhance the communication between the services regardless of their activeness. Producer or consumer can send messages without worrying the availability of the consumer or producer activeness. The only thing that needs is running the message broker
Disadvantages of message broker 😟 👎
- Increase the system complexity. Enabling message broker technology means adding new components to the system architecture. It is not simple as just adding a components. Developers have to go for a set of tasks to complete that and should verify the network security between the components. It can be delivered some additional problems like eventually consistency and data will not update without propagating or processing in the components.
- Initial steep learning curve. Engaging with the message broker technology is not easy as we think. It have to go for a complex configuration process. It has configuration options like size of the queues and messages, delivery setting or messages TTL and behavior of the queue etc.
- Hard to debug. As an example think multiple stages have to process single request and suddenly you have to check the reason for not receiving notification for the send message. In case of such scenario you have to go for every steps to debug and it is time consuming and increase the work load. To reduce this in some extend you can enable message tracking facilities when implementing the system.
Example for message brokers
⭐️Apache Kafka : It is an open source software developed by Apache foundation using two programming language Java and Scala. It is good for processing massive data for long time period.
⭐️RebbitMQ: It is an opensource message broker that has multi protocol capability. It is an Advanced Message Queuing Protocol has since been extended with a plug-in architecture to support Streaming Text Oriented Messaging Protocol.
⭐️ AmazonMQ: It is an alternative provided by the Amazon Web Services for the Apache ActiveMQ and RabbitMQ. It has capability to decrease the managing and maintenance of message broker responsibility from the system owners.
⭐️Amazon SNS: It can be categorized under the publish/subscribe patterns and it provides push notification services powered by the Amazon. It is coming under the Amazon Web Services and not an open-source software. It provides low cost infrastructures for the users.
⭐️ Amazon SQS: It is also another queuing service provided by the Amazon. As same as the Amazon SNS it is also part of AWS. It offers users to free tier for a limited number of message queues and cost effective mechanism. While Amazon SNS has push mechanism(consumer pushing messages) and Amazon SQS has pull mechanism(to pull messages to receivers).
⭐️Redis: It is another message broker that has an in-memory data structure store capability. It is not 100% guarantee for the durability. But if you need a faster broker that can have data loss in some extend this will be the best choice for it.
Applications of message brokers
🌟Microservices
🌟In transactional system
🌟Mobile applications
🌟Controlling data feeds
🌟Crucial API
Stay Safe & Learn New Things!!! :
References