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

Friday, August 27, 2010

BPM11g parallel paths

This builds on from the simple adapters lab documented at
http://niallcblogs.blogspot.com/2010/05/getting-starting-with-bpm-11g-adapters.html

In this simple scenario we augment the functionality from that example with the following –

- Leverage web services to Validate Customer and Check Inventory.
This can be done in parallel

Step 1 - Create demo web service from a Java class

Here's the Java class I'm using.




Expose as a web service




Step 2 - Deploy as a web service to AdminServer & test







Step 3 - Leverage Web Service in the Composite

Copy the wsdl
o E.g.
http://1.1.1.1:7001/BPM-DEMO-WS-BPM-DEMO-WS-context-root/OrderServicePort?WSDL

Drag & drop a Web Service in composite.xml










Step 4 - Leverage in BPM

Create variables to hold the operation responses



Add Check Inventory ServiceTask








Create validateCustomer Service task





Add parallel processing







Connect as follows –



Step 5 - Deploy & Test

Non-domestic input




View instance tracking in em console




Zoom in to ValidateCustomer




We will implement the required error handling in the next post

Thursday, August 19, 2010

Alternative approach to changing WLS external listen address on EC2 image

Thanks to my colleague Prasen -

save the following as update_dns.py

import os

domainHome=os.environ['DOMAIN_HOME']
bpmServer=os.environ['BPM_SERVER_NAME']
ec2DNS=os.environ['ORACLE_HOSTNAME']
externalDNSNameKey='ExternalDNSName'

readDomain(domainHome)
cd ('Servers/'+bpmServer)
currentDNS=wl.get(externalDNSNameKey)
print "Replacing current DNS=%s with %s"%(currentDNS ,ec2DNS)
set(externalDNSNameKey, ec2DNS)
updateDomain()
closeDomain()
print ("EXternal DNS updated")

execute via $SOA_HOME/common/bin/wlst.sh

Tuesday, August 17, 2010

Deploying SOA Composite from local JDev to EC2

Scenario:

I have SOA Suite 11g Patchset 2 running on Amazon EC2.
JDeveloper is installed locally.

As my Cloud ip address can change (I'm not using elastic ip) I make the following entry in my Windows hosts file



I then create a connection in JDev to the SOA Suite App Server -




I then test the connection



However when deploying a composite I get the following error -



To get over this I must simply change the following entry in WLS console to reflect my Amazon ip address.




Select my Server (In my case, AdminServer)


Click on Advanced



Re-start WLS and you're up and running!