Dealing With Expected and Unexpected Faults in BPEL
Join the DZone community and get the full member experience.
Join For Freein bpels in websphere integration developer we can catch exceptions – faults from a bpel, like during an invoke for example.
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
from http://gabrieljeremiahcampbell.wordpress.com/2012/02/29/catching-expected-and-unexpected-faults-in-bpel/
Opinions expressed by DZone contributors are their own.
Comments