Asynchronous Message Based Communication Design Pattern for Microservice Explained with Examples

preview_player
Показать описание
In this video we will learn about Asynchronous Message based Communication design pattern for microservices interaction with the real-world examples. This is a type of communication design pattern for microservices.

When multiple microservices need to call each other and wait for long operations until finished, then we should use asynchronous communication. Asynchronous communication allows the caller to continue working without waiting for a response from recipient. This is often preferred when the caller does not need an immediate response, such as sending notifications like SMS, email for registration or order confirmation in online store etc.

If multiple microservices wants to interacts without creating dependencies or tightly coupling between them, so use asynchronous communication in your microservices architecture, which is commonly referred to as event-driven communication. By using events, microservices can communicate with each other in a loosely-coupled manner without being directly tied to one another. Asynchronous message-based communication provides a flexible and scalable approach to microservice architecture, making it a popular choice among developers.

In Asynchronous communication, using AMQP protocol, the producer sends a message and doesn’t wait for the response from recipient side. It only sends message and expects that it will consume by subscribers via message broker like Kafka and Rabbitmq.

Whenever multiple microservices required to interact with each other and if you want to make them loosely coupled, then we should use Asynchronous message-based communication in Microservices Architecture. Because Asynchronous message-based communication works with events. So, events can place the communication between microservices. We called this communication is an event-driven communication. Also, event-driven communication brings us “eventual consistency”.

You would have noticed, when multiple microservices calling each other in synchronous mode of communication so they form a chain of request. This makes microservices tightly coupled with each other. This is a major pain point of microservice architecture and this is an anti-pattern. This need to fixed & re-design using asynchronous communication. Given the same scenario in Asynchronous communication, multiple Microservices communicate with each other over the message broker system like kafka etc. We can either use Queue or publish/subscribe pattern with message broker systems to achieve asynchronous communication. Both have their use cases & applicability.

** Integration Patterns for Asynchronous communication **
1. Publish subscribe model – publishers publish messages on a topic & subscribers subscribes for that topic. In this model, event broker sends copy of each message to all subscribers of that topic.
2. Message queues – There can be one or more publisher and one or more consumers of the queue. But important point to remember here is one message goes to only one consumer. We use this mode of communication for parallel processing of messages by adding more consumers to process data from queue. More consumers you add more processing power, faster your processing of data from the queue. If you have 10 consumers so 10 messages will be get processed in parallel. E.g., ETL jobs where you extract, transform and load the lots of data. Hence you can use a message broker in between and multiple consumers can process data faster.
3. Many-to-one – only one consumer gets all messages.
4. Request/reply – after a consumer processes a message, it sends a reply to another channel so the producer/publisher can find the results.

** Usage of this Design Pattern **
1. Use this pattern to decouple microservices.
2. Use this pattern to achieve scalability to handle more load by adding more consumers for the queue.
3. Use this pattern to achieve reliability via queue so that if consumer is not available so messages will be stored safe or requeue in case of any failure.
4. Use this pattern to achieve testability.

** Advantages of this Design Pattern **
1. Scalability
2. Reliability
3. Loose coupling
4. Testability

** Chapter Timestamps **
0:00 Welcome to Asynchronous Message based Communication design pattern
1:11 Agenda of the tutorial
2:39 Introduction of Asynchronous Message based Communication design pattern
8:59 Challenges of Synchronous Communication
10:29 Various Integration Pattern for Asynchronous Communication
12:40 Real world example – Publisher Subscriber Model
17:24 Real world example – Message Queue
22:05 Where to use Asynchronous Message based Communication design pattern
22:58 Benefits of Asynchronous Message based Communication design pattern
24:45 Summary of Asynchronous Message based Communication design pattern

#asynchronous #async #microservicedesignpatterns

** CHECK OUR PLAYLISTS **
Рекомендации по теме
Комментарии
Автор

Hello friends, new #video on #asynchronous #messaging #communication #async #designpattern for #microservices #tutorial for #developer #programmers with #examples are published on #codeonedigest #youtube channel.
@java #java #aws #awscloud @awscloud @AWSCloudIndia #salesforce #Cloud #CloudComputing @YouTube #youtube #azure #msazure #codeonedigest @codeonedigest #microservices #microservices #whataremicroservices #microservicesarchitecture #microservicestutorial #asynchronousmessagingkafka #asynchronousmessage #microservicedesignpatterns #microservicepatterns

codeonedigest
Автор

This is so apt. Thank you, I'm going to share

ozifirebrand
Автор

This is more theoretical Sir, would be nice to have some practical examples.

praveenakunuru