MAIN arrow Tutorials-5.1 arrow Exception Handling Part 2: Business Faults (Advanced)

Exception Handling Part 2: Business Faults (Advanced)

Print E-mail

This is Part 2 in a series of 3 tutorials on Exception Handling.

 

In this tutorial you will be shown how you can model and implement exception handling based on business faults in Intalio|BPMS.

 

This tutorial assumes you are familiar with basic modelling concepts such as modelling processes in BPMN, creating mappings, deployment, execution, XML Schemas, Web service basics and Axis 2.  

 

Solutions: 

Business Exception Project:

exceptionhandling_business

 


Part 2: Business Exceptions

 

A business exception is an exception that occurs due to the outcome of a decision in the process. The actual process internally triggers this type of fault. Below is a simple example of how to implement a business exception.

 

diagram2.jpg

 

The process takes in two parameters of type int, then adds the two together to get the total result before responding with this value. In the process we define that if the parameter 'a' is greater than 10 we want to trigger an error which will be caught by the process. Instead of the process continuing as normal, it will proceed down the exception flow and respond with a message containing a business fault.

 

How to create Example

 

1. Create a new Intalio Business Process Project called ExceptionHandlingWithBusinessRule.

 

2. Create a Business Process Diagram with the same name.

 

3. In the diagram we need 2 pools: Client and Process. The client pool represents the participant that will start the process and the Process pool is where we will define the flow objects of our process.

 

4. The Client pool needs to be set  to NonExecutable. To do this, right click on the pool and from the contextual menu select 'Set pool non executable'.

 

5. We need to model the fact that the client will start the process by sending it a message. Create a Task called Send in the Client pool which is the only activity needed in this pool.

 

6. As the process depends on more than one flow object to generate and catch the fault we need a sub-process which behaves as a compound activity.

Create a Sub-process in the Process pool.

 

7. The first thing to occur in the sub-process will be the receipt of a message. This event will actually start the process.

Add a Message Start Event called ReceiveParameters in the subprocess.

 

8. The process evaluates the in-coming data to see whether the parameter 'a' holds a value less than 10 or not. If it is less than true we want to continue to the next activity where we will calculate and send the total result of 'a' + 'b'. Otherwise the process should trigger (throw) an error.

As there are two exclusive out comes we will need an Exclusive Data-Based Gateway to make this decision and control the sequence flow.

Connect ReceiveParameters to an Exclusive Data-based gateway (name it "a<10?"). Create two branches, one going to a Message End event called Send Result and one (default) going to a Error End event called Throw Exception. Error End events trigger (throw) an error which is to be caught by an Error Intemediate Event.

 

9. We need to add in the functionality related to catching and handling the error which can be generated at by the Throw Exception error end event. When Error Intemediate Events are attached to the boundary of activities, they catch error triggers, interrupt the activity and create exception flow.

 

Add an Error Intermediate Event on the bottom boundary of the Sub-process. (call it Catch Business Exception). Using the exception sequence flow, connect this event to a new sub-process which acts as an Exception Handler (call it Business Exception Handler).

 

To do this click on the Error Intermediate Event and move your mouse curser towards to right hand side of the object. You should see the sequence flow connector arrow appear (bold black arrow). If you click on this arrow, holding down your mouse button you can drag it out, then release your mouse button and you will be given a list of possible objects to connect to. Choose a sub-process.

 

10. The catch properties of the Error Intemediate Event need to be set so that the process knows exactly which error fault to catch (there can be more than one).

 

Click on the Catch Business Exception Intermediate Event. In the properties select the field next to Catch and notice how many different faults which can be caught. The list includes the fault that can be thrown from the end event Throw Exception, plus a large set of Standard faults like conflictingReceive. Set the property as displayed below.

Catch: thrown fault: this: Throw Exception

 

catchbus.jpg

 

11. The process can return a fault message as part of the exception handling. This allows the process to complete by returning a specific fault message instead of the normal response message. As the process actually completes, the process state will be 'Completed' instead of 'Failed'.

 

In the Exception Handling sub-process add a Message End Event (call it Business Fault). In our case we have not defined any complex exception handling in the Business Exception Handler although it is possible to define one or more activities in this sub-process.

 

12. Using message links connect the task Send to the start event (request message) and to the end event (response message)

 

13. Connect a message connector from the Message End Event (Business Fault) to the Send task located in the Client pool.

 


Data Management

 

1. The context type of the messages needs to be set. To do this a schema is needed. Create a new schema called RequestResponse.xsd.

 

schema.jpg

2. In this schema create a complex type called Input with a,b elements as type int. Now create two elements, Request of type Input and Response of type int.

 

3. Using the RequestResponse.xsd, Dnd the Request element onto the request message link and dnd the Response element onto the response message link to set their context. The response message from the Business Fault end event can be left as a simple string (default context) as it will be sending a string message.

 

4. Click on the Message End Event (Business Fault) and select the properties tab. Click on the Response fault name property and type "BusinessFault". Notice that the message icon in the diagram changes when you click on save.

 

businessfaultresponsename.jpg

 

5. Click on the Exclusive Data-based gateway. Set the condition to be a < 10. See diagram below.

 

gateway.jpg

 

6. Click on the Send Result message end event. In the mapper, add an operator with a '+' symbol in it. Complete a direct mapping between both of the elements a and b of the $thisReceive_ParametersRequestMsg.body message variable and the '+' operator. Now connect this operator to the thisReceive_parametersResponseMsg.body$ message variable.

 

sendresultbus.jpg

 

7. Now the contents of the fault message body need to be manually set. You could make it equal Error Message: Please enter a value for a less than 10.

Click on the Businss Fault message end event. In the mapper click on the new Oprator button. In the operator enter the text "Error Message: Please enter a value for a less than 10". Finally connect the output of the text box operator to the thisBusinessFaultMsg.body$ message variable.

 

busfaultmsg.jpg

 


Process Deployment and Execution

 

1. Click on Deploy Project to Intalio|BPMS Server button in tool bar.

 

2. Make sure you select all runtime files while exporting to Intalio|BPMS Server.

 

3. Open a web browser, provide url as: http://localhost:8080/bpms-console, which takes to login screen for bpms-console.

 

4. Login with following credentials: username: 'admin' (without quotes) password: 'changeit' (without quotes)

 

5. Bpms-console will be available with deployed processes list

 

6. You should see "ExceptionHandlingWithBusinessRule:InvokeProcess" process with a package name "ExceptionHandlingWithBusinessRule", check the box under project and click to Start.

 

7. This should generate a form with 2 text input fields (a and b).

 

8. Try running the process with diffrent combinations of input.

 

Scenario 1:

a: 1

b: 2

Result: 3.

 

Scenario 2:

a: 11

b: 2

Result: Error message as shown below.

faultbusiness.jpg

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Note: Currently the Intalio console will not display the contents (body) of the fault message. It will only show the type. To see the whole message displayed including the body, you can either access it through the data tab in the console as hown below or run the process via SOAPUI (http://www.soapui.org/ )

 

databusiness.jpg

 

To learn more about Exception Handling for Technical and System faults, you can view the third part of this series here:

Exception Handling Part 3: Technical and System Faults (Advanced)

 

Last Updated ( Aug 08 2008 )
  < Prev Next >