Conditional Start

Concept

To model processes using the conditional start pattern, you use the same web service endpoint for the start event as well as for the intermediate message events. In BPM, a web service endpoint is represented by a reusable message trigger. The start condition and the correlation condition can be independently defined. Usually, the correlation condition is a more specific variant of the start condition. For more information about reusable message triggers, see Creating Reusable Event Triggers

In the conditional start use case, a new process is started only if there are no running processes, which match the correlation condition of the incoming message. The start event is not directly triggered by the message. First, the matching evaluation is done and if there is no running process, the process start for the active version is initiated. That means, all messages that come in at any point in time will then be received by exactly one process instance.

For real-life business examples of the conditional start pattern, see the 'Aggregator' enterprise pattern in SAP Community Network ( http://scn.sap.com/community/process-orchestrationInformation published on SAP site).

Prevention of Manual Process Start

To avoid a multi match scenario through a manual start of a conditional start process, the start process action is disabled in the process repository (http://host:port/nwa/bpm-repository). On the Processes and Tasks tab, an information message is displayed explaining that starting instances is not allowed for processes using the conditional start pattern. The message provides a link to the Web Services Navigator. This link is parameterized with the WSDL URL and the operation name so that you can directly invoke the endpoint.

In addition, the public API rejects invocations of 'startProcess(...)' for conditional start processes. With the isConditionalStart() method, you can check whether a process definition is a conditional start process definition.

Handling of Leftover Messages

Correlation in SAP BPM involves two transactions, message matching and message consumption. This means, a process instance can collect an arbitrary number of incoming web services messages that match the defined correlation condition ("matching" transaction). But these messages are not necessarily consumed by the intermediate message event before the process terminates, for example, the process is manually canceled or completed via the sequence flow. Using the conditional start pattern, these messages must not be discarded but they are appropriately handled. The messages that are not yet consumed are sent to the same endpoint once again as soon as the process instance that received/matched these messages terminates. That means in detail, the messages are provided to a running process instance of the same process definition. If no instance is running one message starts a new process instance of the active process definition. The remaining messages are then provided to this particular instance. And again, the general constraints of the conditional start pattern are valid. That means, all incoming messages are received by exactly one process instance and a new process is started only if there are no running processes, which match the correlation condition of the incoming messages.