Thursday, February 17, 2011

Retrieving ESB exceptions into jBPM

When integrating ESB and jBPM it is possible to take an different jBPM transition in the case that the ESB service throws an exception.
When a ESB service throws an exception, the action pipeline returns the exception details in the Fault section of the message and also in the message Body. As of SOA-P 5.0.2 there is no way by which the contents of the Fault section can be passed back to the invoking jBPM process. However it is possible to retrieve the exception fault code, reason and throwable fields from the ESB message body. The key is to wrap the fields using the single quote character [']

For example
<node name="node1">
<action name="ShipItAction"
class="org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler">
<esbCategoryName>TestSVC</esbCategoryName>
<esbServiceName>Svc2</esbServiceName>
<bpmToEsbVars>
<mapping bpm="theBody" esb="BODY_CONTENT" />
</bpmToEsbVars>
<esbToBpmVars>
<mapping esb="BODY_CONTENT" bpm="theBody" />
<mapping esb="body.'org.jboss.soa.esb.message.fault.code'"
bpm="faultCode" default="" />
<mapping esb="body.'org.jboss.soa.esb.message.fault.throwable'"
bpm="faultThrowable" default="" />
<mapping esb="body.'org.jboss.soa.esb.message.fault.reason'"
bpm="faultReason" default="" />
</esbToBpmVars>
<exceptionTransition>exceptionNOC</exceptionTransition>
</action>
<transition to="end-state1"></transition>
<transition to="ExceptionNode" name="exceptionNOC"></transition>
</node>

No comments:

Post a Comment