Thursday, September 2, 2010

BPM 11g Error Handling sample

Leading on from the previous post -

In this simple scenario we augment the functionality with the following –

Create a subprocess to contain the input validation
o Validate Customer
o Check Inventory

Add error handling to cope with „invalid“ orders
o Invalid Customer
o Insufficient Stock

Both of these are business exceptions, which we will catch (Catch error event). The „errored“ order will be passed on to a HumanWorkflow component through which a SalesRep can fix that order.

To begin with, we will add these business errors to the Java class and redeploy it as a web service to WLS.

--------------------- Revised version of Java class(es) ---

package com.niall;

import javax.jws.WebService;

@WebService(serviceName = "OrderService")
public class OrderService {
public OrderService() {
super();
}
public String validateCustomer(String custName, String email) throws InvalidCustomerException{
String rtc = "Valid";
if (custName.startsWith("Niall")){
throw new InvalidCustomerException("Invalid");
}
return rtc;
}

public String checkInventory(String product, int quantity)throws InsufficientStockException{
String rtc = "SufficientStock";
if (quantity > 100){
throw new InsufficientStockException("Insufficient Stock");
}
return rtc;
}
}


package com.niall;

public class InsufficientStockException extends Exception {
public InsufficientStockException() {
super();
}

public InsufficientStockException(String message) {
super(message);
}
}



package com.niall;

public class InvalidCustomerException extends Exception {
public InvalidCustomerException() {
super();
}

public InvalidCustomerException(String message) {
super(message);
}
}

---------------------- End -----------------------------------

Once re-deployed the WSDL is as follows –



Create the subprocess – ValidateOrder






Create the following artifacts in the sub-process








Deploy & Test

- View trace




Handling business errors
- Once the web service has been redeployed we see the errors in the Errors section of the Business Catalog.





These business errors will be handled by a sub-process that contains a User Task so that the salesRep can go in and amend „errored“ orders.

- Create a new subprocess – ProcessInvalidOrders
- Add a UserTask – ProcessErrors




Drop an Error Catch Event on the sub-process ValidateOrder








- Add a sequence flow from ProcessInvalidOrders back to ValidateOrder






Define the UserTask ProcessErrors








- Set Role to SalesRep and add user weblogic to that role

- Auto-generate Task Form

Deploy & Test

First the Happy path -





- Now the „unhappy“











- Revisit instance trace in em

8 comments:

tomtom said...

Hi,

Is there a way to download your BPM-projects for the BPM-Suite?

Thanks

Niall Commiskey said...

I'll upload this to google apps and let you have the link!

Alex said...

Any chance you can post it somewhere so that I can download it also? Thanks!!!

Niall Commiskey said...
This comment has been removed by the author.
Niall Commiskey said...

I've uploaded the 2 jws files to google docs.

BPM-DEMO-WS.zip contains the web service artifacts leveraged in the BPM project.

My-Test-BPM-DB.zip is the BPM project itself.

Links:
https://docs.google.com/leaf?id=0B7YrnfO7h717MzQ1Njg5ZjYtNzk5ZC00NjE2LTljYzgtN2FhZjdhZDU5ZWJl&hl=en&authkey=CIy7iAc

https://docs.google.com/leaf?id=0B7YrnfO7h717ZjlhMmUwMDctNzUyZi00ODAyLTk4OTAtNjZjZTNjMDNlOTZk&hl=en&authkey=CPOdpvoK

Anonymous said...

Hi

I want to know if below situation can be met using BPM 11g

a) When error happens, error message should be assigned to a particular set of people (for example all the BPM users with a particular user roles) with one person(administrator) having permission to take action.

b) Administrator should be allowed to re-submit the message to BPM process to continue processing from the activity where error occured.

Please let me know if this is possible. If yes, How?

Niall Commiskey said...

This sort of functionality in provided by the Error Hospital on OTN. I'm currently on site in South Africa but will try to do a post discussing this asap

Niall Commiskey said...

This sort of functionality in provided by the Error Hospital on OTN. I'm currently on site in South Africa but will try to do a post discussing this asap