The server has to make sure that subscribers only receive the messages they are interested in. It is possible to filter messages based on different criteria in a publish-subscribe pattern. We will focus on analyzing topic-based filtering, also known as subject-based filtering.
Consider that each message belongs to a topic. When a publisher requests the server to publish a message, it must specify both the topic and the message. The server receives the message and delivers it to all the subscribers that have subscribed to the topic to which the message belongs.
The server doesn't need to check the payload for the message to deliver it to the corresponding subscribers; it just needs to check the topic for each ...