Workflow Manager 1.0 Pub-Sub Activities


Updated: April 20, 2012

Workflow Manager 1.0 enables workflows to subscribe for and receive messages, both for new instance creation as well as correlation to existing instances. While instance creation is driven by a workflow definition’s ActivationFilter, workflow instances that want to subscribe dynamically at runtime for a particular set of correlating messages can do so using the Subscribe and ReceiveNotification activities.

System_CAPS_ICON_note.jpg Note

This model is different than the WF4 model that uses Receive’s CanCreateInstance property in that activation information is specified outside of the workflow (as part of its WorkflowDefinition).

There are four core activities that can be used to receive notification messages:

  • BuildMatchAllFilter – this activity defines the filter that is used to match incoming messages (on the Scope’s Notification endpoint) to the workflow instance. This filter does an exact match on each of the properties specified to the value that is provided. Note: the type defined is relevant to the matching semantics, that is an int of 1 would not match a string “1” in the published message.

  • ReceiveNotification – this activity is used to block the workflow execution until a matching notification message is received. The activity also exposes the message properties and content so that they can be bound to workflow variables. The filter can either be provided explicitly to the activity or a SubscriptionHandle can be used from a previous Subscribe activity. If the former mode is used (providing the filter to the activity), then an implicit unsubscribe is performed after the message is received and delivered to the workflow.

  • Subscribe – this activity can be used to explicitly create the subscription rule based on the input filter. The subscription is stored in a SubscriptionHandle variable, which can be used for subsequent ReceiveNotification activities and/or Unsubscribe activity.

  • Unsubscribe – this activity can be used to explicitly unsubscribe based on an input SubscriptionHandle. Note: if a SubscriptionHandle variable goes out of scope, it will implicitly call unsubscribe such that handles will not be leaked, so the Unsubscribe activity is not always necessary.

Messages are published to the Scope using the Notifications endpoint, or by using the .NET Client API (WorkflowInstanceManager) to publish the notification message. A notification message consists of two parts:

  • Properties – these are a flat list of key-value pairs that can be used for filtering purposes, and can also be accessed in the workflow using the ReceiveNotification’s Properties property.

  • Content – this is the content of the message. A Dictionary<string, object> can be provided in order to map to ReceiveNotification’s Content property (ReceiveParametersContent) or a particular object can be passed which will map to the workflow as the payload of a ReceiveMessageContent.

For more information on messaging in Workflow Manager 1.0, see Inbound Messaging.

Community Additions