Introduction to Pub/Sub
We've mentioned Pub/Sub a few times so far in this chapter, referring to both the messaging pattern and also Google Cloud Pub/Sub, a fully managed messaging system. Let's dive a little deeper into this topic, starting with the pattern itself.
Pub/Sub is short for Publish/Subscribe, which refers to a type of messaging system similar to a messaging broker or a queuing system. However, unlike these systems, a Pub/Sub model has a different architecture. In a Pub/Sub model, messages from different sources or components (the publisher) are stored separately. Other components in the system that need to communicate with the publisher can subscribe to it and become a subscriber. As a result, whenever the publisher sends out a new message, all of its subscribers receive it.
The following screenshot provides an example of a Pub/Sub architecture:
Implementing a Pub/Sub model for our previous...