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

Опубликовано: 05 Октябрь 2024
на канале: Code Decode
77,140
1.7k

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

Udemy Course of Code Decode on Microservice k8s AWS CICD link:
https://openinapp.co/udemycourse

Course Description Video :
https://yt.openinapp.co/dmjvd

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 :    • Core Java frequently asked Interview ...  

Advance Java Interview Questions and Answers :    • Advance Java Interview Questions  

Java 8 Interview Questions and Answers :    • Java 8 Interview Questions(New Features)  

Hibernate Interview Questions and Answers :    • Hibernate Interview Questions Java  

Spring Boot Interview Questions and Answers :    • Advance Java Interview Questions  

Angular Playlist :    • Angular Course Introduction || Angular 8  


SQL Playlist :    • SQL Interview Questions and Answers  

GIT :    • GIT  

Subscriber and Follow Code Decode
Subscriber Code Decode : https://www.youtube.com/c/CodeDecode?...
LinkedIn :   / codedecodeyoutube  
Instagram :   / codedecode25  

#annotations #codedecode #springbootinterviewquestions