Publish-Subscribe Pattern

In the publish-subscribe pattern, producers and consumers exist independently and unaware of one another. Numerous consumers subscribe to events published by various producers. Producers and consumers communicate indirectly via an event bus, which is responsible for connecting published events with interested subscribers. The choice of event bus technology greatly influences the systems properties. Choose the publish-subscribe pattern when multiple, independent components need access to the same information. See the table.

Category

Component & Connector

Elements

Publisher—any component that publishes an event. Specific events published should be described in design documentation.

Subscriber—any component that subscribes to an event.

Event Bus—responsible for registering component subscriptions and delivering published events. The properties promoted by the event bus vary on the specific technology and its configuration.

Relations

Publish—Indicates that a component publishes events to the event bus.

Subscribe—Indicates that a component registers an event subscription.

Rules for Use

All communications in this pattern take place via the event bus. As such all components, must be connected to the bus. Components may be both a publisher and subscriber.

Strengths

Promotes extensibility, reusability, and testability. Depending on the selection of event bus and how it is configured, availability, reliability, and scalability might also be promoted.

Weaknesses

It is difficult to reason about performance in publish-subscribe systems given the independent, asynchronous nature of component communication. The choice of event bus is ultimately responsible for making or breaking a publish-subscribe system. Choose your event bus with care and learn everything you can about how to use it.

Here is an example diagram of a publish-subscribe system:

images/example-publish-subscribe-pattern.png

 

Most publish-subscribe systems define an event specification, which describes events to which components may subscribe. This document also describes event formats as well as the components responsible for publishing events.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.192.141