Asynchronous pattern

When we think of microservices in practical terms, we immediately think of microservices implemented using the REST protocol. However, microservices based on a REST pattern are synchronous and therefore blocking. Sometimes, we need microservices that can be called asynchronously. The asynchronous mechanism is developed with techniques that are specific to each application (message queue, sending asynchronous events, and so on). Let's look at the following diagram:

Service A receives the request from the client and calls Service B in a synchronous manner. However, Service B depends on Service C and calls it asynchronously through a message queue, for example. Service C reads the message from the queue, does the required logical processing, and also returns a response to Service B using the queue mechanism. (We should always keep in mind the independence of the services that are being called.)

A way of communicating between Service B and Service C could be that Service B sends a request message to a QRequest queue and listens for a response from a QReply queue. Service C then reads the request message from the QRequest queue, performs the necessary processing, and sends a response to the QReply queue. Service B reads the response message from the QReply queue, applies a transformation or adds some other information, and then sends the response to Service A. It is clear that the specific details of this implementation should be taken into account, such as waiting for Service C to time out.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.198.174