Asynchronous communication in Microservices Interview Questions and Answers | Part -3 | Code Decode



Published
Microservice asynchronous communication Interview questions and answers we have covered in this video of code decode

Ways to communicate between Microservices


We have seen Synchronous communications through -
Rest APIs
GraphQl
Feign using Eureka discoveries
GRPC ( 10 times faster than REST APIs ) - developed by Google as substitute of REST with many more features.

A synchronous call means that a service waits for the response after performing a request.

Today we will look at ways to do asynchronous communication in java. This communication usually involves some kind of messaging system like
Active Mqs
Rabbit MQs
Kafka

What is Async communication


In Async communication , To initiate such type of communication, a Microservice who wants to send some data to another Microservice publishes a message to a separate component known as a message broker. It is responsible for handling the message sent by the producer service and it will guarantee message delivery.

After the message is received by the broker, it’s now its job to pass the message to the target service. If the recipient is down at the moment, the broker might be configured to retry as long as necessary for successful delivery.

These messages can be persisted if required or stored only in memory. In the latter case, they will be lost when the broker is restarted and they are not yet sent to the consumer.

Since the broker is responsible for delivering the message, it’s no longer necessary for both services to be up for successful communication. Thus async messaging mitigates the biggest problem of synchronous communication - coupling.

What is Async communication

In Async communication , To initiate such type of communication, a Microservice who wants to send some data to another Microservice publishes a message to a separate component known as a message broker. It is responsible for handling the message sent by the producer service and it will guarantee message delivery.

After the message is received by the broker, it’s now its job to pass the message to the target service. If the recipient is down at the moment, the broker might be configured to retry as long as necessary for successful delivery.

These messages can be persisted if required or stored only in memory. In the latter case, they will be lost when the broker is restarted and they are not yet sent to the consumer.

Since the broker is responsible for delivering the message, it’s no longer necessary for both services to be up for successful communication. Thus async messaging mitigates the biggest problem of synchronous communication - coupling.

What is Async communication

A relevant point here is that there, the sender doesn't need to wait for the response. It might be sent back from the receiver later as another asynchronous message.

The intended service receives the message in its own time. The sending service is not locked to the broker. It simply fires and forgets.

What if the message broker is down?

A message broker is a vital part of the asynchronous architecture and hence must be fault tolerant

This can be achieved by setting up additional standby replicas that can do failover. Still, even with auxiliary replicas, failures of the messaging system might happen from time to time.

If it’s essential to ensure the message arrives at its destination, a broker might be configured to work in at-least-once mode. After the message reaches the consumer, it needs to send back ACK to the broker. If no acknowledgement gets to the broker, it will retry the delivery after some time.



Most Asked Core Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXscoyL5XEZoHHZ86_6h3GWE1

Advance Java Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Java 8 Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdeusn4OM33415DCMQ6sUKy

Hibernate Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsdC-p2186C6NO4FpadnCC_q

Spring Boot Interview Questions and Answers : https://youtube.com/playlist?list=PLyHJZXNdCXsexOO1VQ4vs-BM2-8CKrixd

Angular Playlist : https://www.youtube.com/watch?v=CAl7RQSdq2Q&list=PLyHJZXNdCXsfxRtDwtGkDD_lLfTWc1g0i


SQL Playlist : https://www.youtube.com/playlist?list=PLyHJZXNdCXse86eLuwy5uZohd_bddE9Ni

GIT : https://youtube.com/playlist?list=PLyHJZXNdCXscpl6pxOnL2lRWJlzvzjyZE

Subscriber and Follow Code Decode
Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?sub_confirmation=1
LinkedIn : https://www.linkedin.com/in/codedecodeyoutube/
Instagram : https://www.instagram.com/codedecode25/

#annotations #codedecode #springbootinterviewquestions
Category
Job
Be the first to comment