3. Triggering Workflows with vCloud Notifications : 3.5 Process Notifications and Trigger Workflows
   
3.5 Process Notifications and Trigger Workflows
The Handle vCloud Director message notifications policy and the Workflow Runner workflow elements from the package are used to process incoming messages and trigger workflows.
Figure 14. Policy Element: Handle vCloud Director message notifications
 
The AMQP plug-in provides the ability to add a policy element to a policy with a type of AMQP:subscription and an OnMessage trigger event. The Handle vCloud Director message notifications policy is set up to start a workflow that processes a received message. The policy uses a script to start the Workflow Runner workflow with the subscription object that received the message and the message body passed in as input parameters.
Figure 15. Workflow Schema: Workflow Runner
 
The Workflow Runner workflow has the following main steps:
1. Read properties of the subscription.
2. Convert message contents into objects.
One parameter passed to this workflow is the subscription object that received the message. The Create a vCloud Director notification subscription workflow sets custom properties on the subscription objects that it creates. One custom property set on the subscription is the workflow to trigger. Another custom property is the vCloud Director host that published the message.
The Workflow Runner workflow reads these custom properties to determine which workflow to trigger in response to the received message and which parameters to pass in to the workflow. Using the vCloud Director host custom property, the Workflow Runner converts the references in the message received by the subscription into objects that match input parameters for the workflow. Finally, the Workflow Runner triggers the workflow.
Because the Workflow Runner can process any type of message, it can set various input parameters. The following table describes the input parameter types that the Workflow Runner can set.
Table 8. Input Parameter Types Set by Workflow Runner
Parameter Type
Requirement
Organization
Input must be of type vcloud:Organization.
Notification type
Input must to be of type vcloud:EventType.
Operation success
Input must be specifically named operationSuccess.
User
Input must be of type vcloud:User.
Entity
Input must be of one of the types listed in
Table 4 for the example named entityCatalog and/or with a type of vcloud:Catalog.
TaskOwner
Input must be of one of the types listed in
Table 4, for the example named taskOwnerCatalog and/or with a type of vcloud:Catalog.
BlockingTask
Input must be of type vcloud:BlockingTask.
Task
Input must be of type vcloud:Task.
 
The consumed message can be produced by a vCloud Director notification or by a vCloud Director blocking task. The notification is used to trigger a workflow after an event happens. The blocking task is used to trigger a workflow before an event happens.