Wednesday, April 15, 2015

Oracle BPM 12c Events (Part 2 of 3): End Events

End events define how a process should finish and just like with start events, processes can have more than one end event.

As you can see from the sample process below, we are provided with a plethora of end events that include a “None End” event,  a “Message Send” event, a “Signal” event and a “Terminate End” and “Error End” event.

The “None End” event is the default end event in a manual and reusable process and as it’s name implies, it is used when your process doesn’t need to perform any action upon completion. When all process instance tokens reach the “None End” event, the instance is completed.

The "Message End" event, as the name implies, will send a message before an instance completion and is especially useful when you want to trigger another process or instance. The "Message End" event has one unique particularity, it can only be used with either a message start event or a message catch event.

The "Signal Event" will publish a signal before completion.

The "Terminate End" is used to terminate, immediately, without any error handling, a process.

The "Error End" will throw an error before completion. This type of end event is used most commonly in subprocesses to trigger an exception to a main process.

Let's see how you can use these end events in practice.

Create the basic BPM application and BPM project (named both application and project "EndEventsDemo") and select "Composite with BPMN Process" in step 3.

 In the "BPMN 2.0 Process Wizard" specify a process name, for example DemoProcess and select "Asynchronous Service" as the service type and click "Next".

In the "Arguments" screen create an input argument to define the end event type as a user input to the process and click "Finish".

On the process canvas add a "None End", a "Signal End", a "Terminate End" and an "Error End" event. You should have a total of 5 end events for your demo process.

The new end events that you have added to your process are showing an error. This is because they don't have any incoming sequence flows. Therefore, place an exclusive gateway on the default sequence flow between the "Message Start" and "Message End" events and add conditional sequence flows from the exclusive gateway to a each of your other end event types.

Make sure that you define a condition expression for each of the non-default outgoing sequence flows. In my case, I've set the condition expression to the "Message End" type to bpmn:getDataObject('endType') = "message"

You should also notice a warning on the "Signal End" and "Error End" events. This is because these two end events don't have an implementation defined. So let's quickly implement these two end events.

For the purpose of this, I will create a new XML schema with a single element called "fraud" with a child string element called "transactionId".

Under the "Business Components" I have created a new "Business Exception" called "InvalidSSN" of error type string.

and created a new "Event Definition" called "FraudCheckEventDefinition" with an event called "FraudCheckEvent" of type "fraud " (the element type that I've created in my "FraudCheck" XML schema.

Go to your process and select the "InvalidSSN" exception type for the "Error End" event and the "FraudCheckEvent" for the "Signal End" event. 

Deploy your process and instantiate a new instance of your process using the Enterprise Manager. In the endType input parameter enter one of the values that you have defined in your complex gateway outgoing sequence flow (for example, "message").

Go to the flow instances and inspect your instance; you should notice that your process ended using the "Message End" event.

Initiate a new instance but this time use "signal" as the endType input parameter (assuming that your outgoing sequence exclusive gateway condition to the "Signal End" event is "signal"). Your process should have ended using the "Signal End" event.

Download sample application: End Events

No comments:

Post a Comment