Publish–subscribe pattern
- Snippet from Wikipedia: Publish–subscribe pattern
In software architecture, publish–subscribe or pub/sub is a messaging pattern where publishers categorize messages into classes that are received by subscribers. This is contrasted to the typical messaging pattern model where publishers send messages directly to subscribers.
Similarly, subscribers express interest in one or more classes and only receive messages that are of interest, without knowledge of which publishers, if any, there are.
Publish–subscribe is a sibling of the message queue paradigm, and is typically one part of a larger message-oriented middleware system. Most messaging systems support both the pub/sub and message queue models in their API; e.g., Java Message Service (JMS).
This pattern provides greater network scalability and a more dynamic network topology, with a resulting decreased flexibility to modify the publisher and the structure of the published data. According to Gregor Hohpe, compared with synchronous messaging patterns (such as RPC) and point-to-point messaging patterns, publish–subscribe provides the highest level of decoupling among architectural components, however it can also couple them in some other ways (such as format and semantic coupling) so they become messy over time.