In this video, learn some common use cases for interservice communications patterns that can leverage asynchronous messaging.
- [Instructor] One of the most common forays into asynchronous communications and messaging is for interservice communications. Often, you find yourself in a situation where you just need to push a message to a remote system to do work and you don't want to block on the downstream system completing its tasks. Now, while I'm just going to introduce them here, I'm hoping that this will get you thinking about the use cases before we do a deep dive. Point to Point messaging is one of the easiest ways in a mircoservices architecture to move to asynchronous messaging. These calls can replace traditional RESTful calls between services where the response is not needed or can be received in an out-of-band process. In this model, there is a single producer that creates a message and puts it onto the message broker. There is also a single consumer who responds or listens to the message and does some action on it. It is important to remember that it is a send and forget model. The producer creates the message, dispatches it and goes on. As such, any kind of response is usually another point to point message. The Publish and Subscribe or pub/sub for short, is a different model for interservice communications. It's use cases are more specific than in microservices architecture but nonetheless, equally valuable. This actually becomes a very powerful pattern in distributed computing as we will discuss. Once again, we usually have a single producer who creates the message and dispatches it to the message broker. However, in this model, there is one or more subscribers who listen for messages and act on their own accord. The distinction here is you can have multiple consumers of the same message which is why this becomes a little less common in a microservices architecture as we don't often find ourselves broadcasting a message to many different services in the exact same format. Once again, however, it is a send and forget model where the producer isn't waiting on any kind of response before continuing its work. In this model, there is also a concept of a durable subscription. In traditional pub/sub, if a subscriber isn't there, it won't get the message. However, if the subscriber is durable, there is a guarantee that the message will be delivered at some point once the subscriber is available again. This is a specific registration process that allows this durable subscription but it is very critical when messages must be acted on, even if the processes have been terminated in the system.
- Gains and tradeoffs of asynchronous communications
- Use cases for interservice communication patterns
- Event-driven microservices
- Use cases for choreographed and orchestrated events
- Streaming data platforms
- Data flows, migration, and synchronization