Apprenda's Publish / Subscribe Message Bus

The Platform fabric is built upon a robust message bus that ushers service traffic dynamically between application components. In most cases, service calls are targeted to a specific type of service endpoint, which the Platform routing mechanisms locate and facilitate. However, in some cases, you may want to simply “listen” for certain events across all of your applications, and action upon event “publications”.  For this purpose, the Platform provides a basic but extremely useful pub/sub capability.

Context Scope

Publishers and subscribers use named events within a specific scope to communicate with each other:

SaaSGridContext - an event published at this scope will broadcast across the entire Platform, and subscribing guest application will receive notification and the event payload.

ApplicationContext - an event published at this scope will broadcast across only .NET service and UI workloads that belong to the same application as the publisher.

Event Payload

A publisher may fire an event with any type of object as its payload.  Subscribers must listen for not only the proper event (by name) but also the correct type of payload.  Here is a simple example:

Service 1 contains the following code, used to publish an event called “ThresholdCrossed”, with a payload that is a DateTime object containing when the threshold was crossed:


Note that because this event is published at the SaaSGridContext scope - any other guest app on the Platform may contain subscribers; and they will subscribe like this:

SaaSGridContext.Current.EventManager.Event<DateTime>("ThresholdCrossed").OnEvent +=
date => {
// here we can do something with date, which is the DateTime payload contains in the published event.