Assembly: mindtouch.dream
Class:MindTouch.Dream.PubSubService
SID: sid://mindtouch.com/dream/2008/10/pubsub
The PubSubService accepts subscription sets from subscribers and filters and propagates messages it receives accordingly. In general, the location of an PubSubService will be provided by the environment to each service via the <uri.subservice> configuration value. The URI provided in the configuration value is rooted at {service}/subscribe, so that subscription calls are done against the provided URI, without the postfix.
An EventPublisher service receives messages. It either is an EventSubscriber or is associated with at least one via another transport (such as Xmpp). In general, the location of an EventPublisher will be provided by the environment to each service via the <uri.pubservice> configuration value. The URI provided in the configuration value is rooted at {service}/publish, so that publication of messages are done against the provided URI.
| Verb:Suffix | Description |
| POST:publish | Publish a message onto a channel |
| POST:subscribers | Initialize subscriptions from a subscription set |
| GET:subscribers | Retrieve the combined subscription set |
| GET:subscribers/{subscription-location} | Retrieve present subscription set |
| PUT|POST:subscribers/{subscription-location} | Replaces an existing subscription set |
| DELETE:subscribers/{subscription-location} | Delete an existing subscription set at the location |
<subscription-set max-failures="...">
<!-- the uri of the service registering the subscription set -->
<uri.owner>...</uri.owner>
<!-- the set can have 1 or more subscription blocks. @id will be assigned by
the server if none was provided -->
<subscription id="...">
<!-- each subscription can include 1 or more channels. Channels are OR-ed
for matching events. Channels can use a wildcard '*' for host
and end of path -->
<channel>channel:///some/channel</channel>
...
<!-- each subscription can include 0 or more resources to subscribe to. Resources
are OR-ed for matching events. Resource Uri's can use a wildcard '*' for host
and end of path -->
<uri.resource>http://canonical/path/to/resource</uri.resource>
...
<!-- There can be zero or one proxy. If it exists it is used as the
destination for matched events -->
<uri.proxy>...</uri.proxy>
<!-- There can be 1 or more recipients. If there is more than one recipient
a proxy must be defined. If the event has recipients, the intersection
between event and subscription recipients is used to filter matches. Recipient
comparison is done solely on the recipient uri, although end points can employ
their own contracts based on additional data included in the recipient document -->
<recipient>
<uri>...</uri>
...
</recipient>
...
</subscription>
...
</subscription-set>
Channels are URIs. There generalized format is:
{system}://{instance}/{action-path}
In subscription sets, channels accept wild cards at the instance or end of action. The following are all valid channel patterns:
channel://*/some/exact/path foo://some-instance/wildcard/path/* channel://*/*The PubSubService is also a publisher itself of change events on its subscription set, which it POSTs against subscribers that subscribe to the channel pattern
pubsub:///*
Scenario: PubSubService p1 intends to publish events that PubSubService p2 has subscriptions for into p2. For this to happen, p1 must subscribe to p2 in such a way that subscription set changes are published into a named subscribers endpoint.
Scenario: PubSubService p1 intends to proxy events received by PubSubService p2 for its own subscribers. For this to happen, p1 must subscribe to events on p2 matching its combined subscription set and also push updates to this subscription set to p2.
Publish an event. At service start-up, every service will be provided the uri to a publish feature via uri.publish. This is also exposed as a Plug at the Publish property of the service. The uri is rooted at the publish feature, i.e. no additional "publish" is needed for the post.
This feature is internal, but the services provided the URI for this service are generally also provided the appropriate cookie along for the automatically provided publish.
The request body can be anything, accompanied by a proper mime-type. However, there are some header requirements.
| Headers | Occurence | Description |
| X-Dream-Event-Id | 1 | The id of the event. If one was not provided, one will assigned and returned in the response body |
| X-Dream-Event-Origin-Uri | 1+ | one or more resource uri's for resources related to the event. Generally additional uri's denote previous locations of that resource |
| X-Dream-Event-Channel | 1 | the channel this event is published to |
| X-Dream-Event-Via-Uri | 0+ | zero or more publishers the event has passed through (to determine circular routes) |
| X-Dream-Event-Recipient-Uri | 0+ | a list of recipients authorized to receive the event. Generally should be set by a EventSubscriber based on the set of recipient subscribers so that known downstream subscribers are in this list |
| Response | Response Body | Description |
| Ok (200) | see below | operation completed successfully and a new event was created |
| Bad Request (400) | text/html | request could not be completed, because of invalid data in the request |
The response body is always an empty envelope with an id, either the one provided in the header by the caller or assigned by service, if none existed.
<event id="ad232fdd0ed" />
Register a subscription set with the EventSubscriber which is used to filter and dispatch incoming events. Matching events are dispatched to the the uri.recipient or uri.proxy in the event format specified for EventPublisher. If the EventSubscriber is one in a chain of pub/sub services, it builds a combined subscription set from all subscriptions for all recipients it handles and posts it to the upstream publisher as its subscription set.
Xml document following the subscription set specified above.
| Status | Response Body | Description |
| Created (201) | text/xml | operation completed successfully. Response contains Location header |
| Conflict (409) | -- | A set for that owner already exists. Response contains a Content-Location header for the location of the conflicting subscription set |
<subscription-set> <uri.location>...</uri.location> <access-key>...</access-key> </subscription-set>
The response also includes a Location header that has the access-key appended as a query-argument. Access is granted to the location either by using the location uri from the header directly (which may expose the access key), or by constructing an access-key cookie for the location.
Retrieve the combined subscription set that the EventSubscriber pushes to an upstream subscriber
| Status | Response Body | Description |
| OK (200) | text/xml | operation completed successfully |
Retrieve a subscription set, along with each subscriptions statistics
A private key is issued upon creation of the location
| Status | Response Body | Description |
| OK (200) | text/xml | operation completed successfully |
Replace an existing subscription set. This feature supports both PUT and POST, primarily since it is used as a publish endpoint for chaining and publishing only allows post. It is preferable to use PUT if not done as part of chaining
A private key is issued upon creation of the location
| Status | Response Body | Description |
| OK (200) | -- | operation completed successfully |
Remove an existing subscription set
A private key is issued upon creation of the location
| Status | Response Body | Description |
| OK (200) | -- | operation completed successfully |
| Images 0 | ||
|---|---|---|
| No images to display in the gallery. |
Copyright © 2011 MindTouch, Inc. Powered by