Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Dealing With Expected and Unexpected Faults in BPEL

DZone's Guide to

Dealing With Expected and Unexpected Faults in BPEL

Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

In BPELs in WebSphere Integration Developer we can catch exceptions – faults from a BPEL, like during an invoke for example.

image

What happens when we want to catch an exception that is not necessarily a fault and could stem from the underlying  system or the application behind the invoke(in the diagram it is InvokeSomeOperation)?

As you can see in the above excerpt of a BPEL, we have a known Fault called MyApplicationFault in the catch and then in the Catch All we deal with any unknown faults that are not MyApplicationFault and just exceptions that are not BPEL faults at all.

So if we have a NumberFormatException for example it will pass the MyApplicationFault catch and go the Catch All.

Now if we want to transform any exception that comes through in a BPEL exception that will be like a fault we can use an anonymous class in a snippet:

new BpelException(){

    public String getFaultName() {

    return “MyFaultName”;

    }

    public String getMessage() {

    return caughtException.getMessage();

    }

};

 

This way we can handle the exception elsewhere in the BPEL Process using:

com.ibm.bpe.api.BpelException bpelexception = getCurrentFaultAsException();

logger.debug(“Fault Name” + bpelexception.getFaultName());

bpelexception.printStackTrace( System.out);

Throwable rootCause = bpelexception.getRootCause();

So the Catch All can accept normal java exceptions as well as BPEL faults Smile

 

From http://gabrieljeremiahcampbell.wordpress.com/2012/02/29/catching-expected-and-unexpected-faults-in-bpel/

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:

Opinions expressed by DZone contributors are their own.

THE DZONE NEWSLETTER

Dev Resources & Solutions Straight to Your Inbox

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

X

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}