Subscribing

The subscribing module is composed of a set of interdependent objects (MessageBoard, EventItem, Subscription and MessageHandler) to assist with subscribing to producers based on the “blackboard” pattern. The central object is the MessageBoard that holds items generated from events. These events are the result of subscriptions (Subscription) placed on a producer (Producer) object. When a producer generates an event due to a subscription, the event is packaged within an EventItem object before posted to the MessageBoard.

The EventItem contains both the event data as well as the necessary objects to handle the data:

  1. Subscription: in case the event should cause the subscription to be removed

  2. MessageHandler: for conveniently tying specific instructions to handler events from a subscription

Basic Domain Model

The diagram below explains the concept by means of a basic UML domain model.

../_images/domain_model.jpg

A Messageboard gets populated by events as a consequence of Subscriptions on Producers producing new events. For each event, a means of handling it (or consuming of the event) is provided in the form of a Handler. The handler could be for example something that checks the event value against an expected order of events and unsubscribes a subscription when a specific condition is met. The Subscription object ties therefore not only a subscription to a Producer, but also a Handler to the Subscription.

Basic Design

The subscribing module defines a set of interdependencies and relationships on abstract classes as a framework for resting the implementation of these classes. In order to provide the client software with maximum flexibility, a variety of ways is provided for calling and acting upon these classes. However, care should be taken to prevent circular dependencies. The basic structure is depicted as UML diagram below:

../_images/base_dependencies.jpg

This framework is then used to create the actual implementations of the classes as depicted in the diagram below:

../_images/interdependencies.jpg