Service Reports
Publishing Reports
If a service agent needs to publish a report, the member function "publishReport()" is used. In publishing a report, it will generally be the case that a service agent does it without caring who may actually be subscribed to that report. This is often referred to as anonymous publishing and results in a more loosely coupled system which can adjust dynamically to changes. That is, it is not necessary to hardwire into a service to whom it should send a report, instead, a service which is interested in the report will subscribe to it and the underlying system will handle everything else.
self.publishReport("subject.string","value")
self.publishReport("subject.integer",12345)
self.publishReport("subject.float",1.2345)
self.publishReport("subject.list",[1,2,3,4,5])
self.publishReport("subject.dict",{"one":1,"two":2})
When publishing a report, a service agent needs to supply a subject which in some way identifies the purpose of the report, as well as the content of the report. It is through subscription to specific subjects that subscribers will indicate their interest in specific reports. The subject name assigned to a report can have any value, but it is suggested that a hierachical naming convention be used. That is, use one or more name components, where each component is separated by a period.
heartbeat news.local.sanitation news.domestic.politics notifications.shutdown
By using a naming hierarchy, it becomes possible to aggregate reports into groupings which can then be easily subscribed to as a whole. Note that there is nothing special about a period as the separator for the name components. Other separators which are often used for performing the same task are a slash or a colon.
Monitoring Reports
A desire to subscribe to reports published by another service is indicated by a service agent calling the "monitorReports()" member function. In setting up such a subscription, the service agent must supply a callback function to be called when a report is received, the name of the service or the service binding object of the specific service agent to which it is subscribing and an indication of what reports it is interested in.
In the simplest case, a subscription can supply the exact same subject name under which a report is published. Alternatively, it can use special wildcard characters to allow it to pick up reports published against related subjects. The two special wildcard characters which can be used are "*" and "?". These can be incorporated anywhere in the subscription pattern.
The "?" can be used to match a single character within the subject name, where as a "*" will match any number of characters. Note that each will match any character, including a period or slash. As such,
48