Defining Publish and Subscribe Message Routing
InterSystems IRIS™ supports publish and subscribe message delivery. Publish and subscribe
refers to the technique of routing a message to one or more subscribers based on the fact that those subscribers have previously registered to be notified about messages on a specific topic. This chapter discusses the following topics:
Publish and Subscribe Overview
Publish and subscribe messaging works based on the runtime interactions between:
is a production message. An external system receives a request and directs it into InterSystems IRIS, which converts it to a production message and sends it to a special-purpose business operation for processing.
is a string that characterizes the contents of a message. InterSystems IRIS does not define any topics; users and their applications define the meanings of topics and subtopics.
A topic string has the form A.B.C.D
, where A
, and D
strings delimited by the .
(period) character. A topic can contain any number of subtopics; each of these subtopics can be up to 50 characters long. The following are all valid topic strings:
You can specify a range of topics by using *
(the asterisk) as a wildcard character. For example:
is an entity (a user or an external system) that might be interested in a specific topic or set of topics. A subscriber entry specifies how that entity wishes to be contacted; that is, how InterSystems IRIS should send a message to it.
associates a subscriber with a topic
Suppose you have three subscribers:
In that case, you could define the following subscriptions:
Baker is notified whenever the exact topic Doctor.ICU.88495
is processed. In addition, Baker is notified whenever any message related to patients in the lab are processed.
Charlie is notified whenever anything related to a doctor or patient with an identifier of X3562564
Implementing Publish and Subscribe Message Routing
Creating a Publish and Subscribe Operation
Configuring Publish and Subscribe
When you configure publish and subscribe features for a production, the basic steps are:
Create a list of subscribers.
Create subscriptions to associate subscribers with topics.
Publish and subscribe messaging uses the following classes in the EnsLib.PubSub
||Business operation that provides publish and subscribe message routing.
||Request class that packages requests to the PubSubOperation class. Specifies which topic and DomainName should be used to determine how the message should be routed. Optionally, the Request may also contain the message being routed, but the PubSubOperation does not need this information to return its TargetList.
||Response class that packages responses from the PubSubOperation class. Contains a collection of Target objects called TargetList, which the calling business process consults before dispatching the message to the required destinations.
||Persistent class that represents individual subscribers. These are entities interested in being notified when certain messages arrive. The Subscriber class includes any information needed to contact the actual subscriber.
||Persistent class that stores the association between a given Subscriber and a topic string.
||Persistent class that holds the set of PubSub domain names. Domain names are optional; like namespaces, domains provide a way to keep different subscription lists separate.
||Utility class that provides a programmatic API for creating and deleting domains, subscribers, and subscriptions.
||Persistent class that provides details about how to route a message to a destination outside a production. The Target object has a Target property that identifies a configured business process or business operation within the current production. The Target object has an optional Address property that can specify an external address, for example an email address.
Instead of using the Management Portal, you can manipulate the objects directly using methods in the EnsLib.PubSub.Utils
does not actually send messages to subscribers; instead, it provides a mechanism to quickly find the set of interested subscribers for a given topic. It is the responsibility of a business process that calls the PubSubOperation
to dispatch messages to subscribers.
At runtime, an incoming message is sent to a business process, which examines it for identifying details. Based on this analysis, the business process assigns the message a specific topic string that does not contain any wildcard characters. It then creates an EnsLib.PubSub.Request
message that contains this topic string and sends it to the PubSubOperation