Enforcing Order for Process Execution

If you wish process instances to execute in a certain order, you can use Wait and Notify activities to accomplish this. This requires using some portion of the incoming event to determine the order.

For example, an application may assign a priority number to incoming orders. This may be important when accepting requests for a limited resource, for example, airplane seats or available space in a university class. The orders must be processed in order of priority to ensure that orders with the highest priority number have access to the resource first. The following figure illustrates an example process definition that orders incoming events.

Ordering incoming events

In this process definition, new requests are submitted through a web interface. A new process is started for each request, and a priority number (an ordered sequence) is given with each request. The order with priority number 1 is submitted, and processed immediately. When the first order is completed, a Notify is sent with its key set to 1. All other orders transition to the Wait activity. These orders are suspended until a Notify activity is executed whose key is equal to their priority number minus one (that is, the order with the next highest priority number).

Using this technique, orders are processed in the order of their priority, regardless of when the order is submitted. All orders create a process instance and then immediately suspend until the notification is sent from the order with the next highest priority.