If you know a workflow will have to wait for a response from an outside source during its run, but do not know how long that wait will last, you can implement it as a trigger-based long-running workflow. A trigger-based long-running workflow waits for a defined trigger event to occur before resuming.

About this task

You implement a workflow as a trigger-based long-running workflow by using the Waiting Event element. When the trigger-based long-running workflow arrives at the Waiting Event element, it will suspend its run and wait in a passive state until it receives a message from the trigger. During the waiting period, the passive workflow does not consume a thread, but rather the long-running workflow element passes the workflow information to the single thread that monitors all long-running workflows in the server.

Prerequisites

  • Create a workflow.

  • Open the workflow for editing in the workflow editor.

  • Add some elements to the workflow schema.

  • Define a trigger event that is encapsulated in a Trigger object.

Procedure

  1. Drag a Waiting Event element from the Generic menu to the position in the workflow schema at which you want to suspend the workflow's run.

    The scriptable task that declares the trigger must immediately precede the Waiting Event element.

  2. Click the Edit icon (Edit icon) of the Waiting Event element in the workflow schema.
  3. Provide a description of the reason for the wait in the Info properties tab.
  4. Click the Attributes properties tab.

    The trigger.ref parameter appears in the list of attributes.

  5. Click the trigger.ref parameter's Not set link to bind the parameter to an appropriate Trigger object.

    The Waiting Event selection dialog box opens, presenting a list of possible parameters to which to bind.

  6. Select a predefined Trigger object from the proposed list.

    This Trigger object represents a trigger event that another workflow or workflow element defines.

  7. Define any exception behavior in the Exceptions properties tab.
  8. Click Close.
  9. Click Save at the bottom of the workflow editor.

Results

You defined a workflow element that suspends a trigger-based long-running workflow, that waits for a specific trigger event before restarting.

What to do next

You can run a workflow.