Introducing the Publish/Subscribe Pattern
The Publish/Subscribe Pattern is a Messaging Pattern where the emitters of the messages, called the publishers, multicast messages to a number of recipients, called the subscribers, that have expressed their interest in receiving such messages. The key concept of this pattern, which is also commonly referred to as the Pub/Sub Pattern in short, is to provide a way to avoid dependencies between the publishers and their subscribers.
An extra concept of this pattern is the use of topics that are used by the subscribers in order to express that they are only interested in messages of a specific type. This way, publishers filter subscribers before sending a message and distribute that message only to the appropriate ones, thereby reducing the amount of traffic and work required on both sides.
Another common variant is to use a central, application-wide object, known as the broker, that relays messages produced by the publishers to the relevant subscribers...