Oracle SOA Fault Management Framework :
http://ofmxperts.blogspot.in/2011/11/basics-of-fault-management-framework-in_23.html
http://docs.oracle.com/cd/E28280_01/dev.1111/e10224/bp_faults.htm
Handling Custom Faults in SOA 11g using fault policies
We will be using 2 BPEL processes here.
1) Fault BPEL - It will always throw a custom fault
2) Main BPEL - It will invoke the Fault BPEL and capture the custom fault using the fault policy.
FAULT BPEL PROCESS
=====================
1) Create a synchronous BPEL process with name FaultBPELProcess to throw business fault.
2) Customize the file FaultBPELProcess.xsd to add the fault message type.
COMPLEX TYPE
+++++++++++++
<element name="faultarea">
<complexType>
<sequence>
<element name="code" type="string"/>
<element name="summary" type="string"/>
<element name="details" type="string"/>
</sequence>
</complexType>
</element>
3) Customize the file FaultBPELProcess.wsdl to add the fault BusinessFault in the opertions and the fault message type.
a) <wsdl:message name="Fault">
<wsdl:part name="payload" element="client:faultarea"/>
</wsdl:message>
b) Under operations tag added
<wsdl:fault name="BusinessFault" message="client:Fault"/>
4) Now add Throw Activity with namespace 'http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess' and LocalPart 'BusinessFault' and FaultVariable as 'FaultVar'.
5) Deploy the BPEL process to the application server.
MAIN BPEL PROCESS
==================
1) Create BPEL process with name MainBPELProcess to handle the fault thrown by FaultBPELProcess.
2) Customize file MainBPELProcess.xsd to add:
<element name="faultarea">
<complexType>
<sequence>
<element name="code" type="string"/>
<element name="summary" type="string"/>
<element name="details" type="string"/>
</sequence>
</complexType>
</element>
3) Customize file MainBPELProcess.wsdl to add:
a. <wsdl:message name="Fault">
<wsdl:part name="payload" element="client:faultarea"/>
</wsdl:message>
4) Create a partnerlink and make a call to the FaultBPELProcess.
5) Add Invoke Activity to the Main Scope and do the following:
a. Point the invoke activity to the partnerlink used for calling FaultBPELProcess.
b. Create the input and output variables.
c. Click ok to save.
6) Add activity Assign before the invoke activity. Assign the input of the MainBPELProcess to the input variable used in the invoke activity.
7) To the Main Scope add the Catch Activity to catch the Business Fault. Add Reply Activity under the Catch to reply the calling party with the fault variable.
8) Change the composite.xml to add the following:
<property name="oracle.composite.faultPolicyFile">fault-policies.xml</property>
<property name="oracle.composite.faultBindingFile">fault-bindings.xml</property>
9) Deploy the BPEL process to the application server.
FAULT POLICY
============
1) Create fault-bindings.xml.
2) Add the following to it:
<component faultPolicy="BusinessFault">
<name>MainBPELProcess</name>
</component>
3) Create fault-policies.xml.
4) Add the following:
a. faultName, namespace - http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess, the one thrown from the FaultBPELProcess.
b. name - BusinessFault, the local part of the throw activity in FaultBPELProcess.
c. Add the conditions and the actions in the fault policy.
5) Place both the files in MainBPELProcess folder.
================================================================
FAULT POLICY
+++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<faultPolicy version="3.0" id="BusinessFault"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Conditions>
<faultName xmlns:bns="http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess"
name="bns:BusinessFault">
<condition>
<!-- Let the component handle this specific business fault -->
<action ref="ora-retry"/>
</condition>
</faultName>
</Conditions>
<Actions>
<!-- This action will attempt 3 retries at increasing intervals of 2, 4, 8 seconds. -->
<Action id="ora-retry">
<retry>
<retryCount>3</retryCount>
<retryInterval>2</retryInterval>
<exponentialBackoff/>
<retryFailureAction ref="aia-ora-java"/>
<retrySuccessAction ref="aia-ora-java"/>
</retry>
</Action>
<!-- This action will attempt 7 retries at increasing intervals of 2, 4, 8, 16, 32, 64, 128 seconds. -->
<Action id="aia-ora-retry">
<retry>
<retryCount>7</retryCount>
<retryInterval>2</retryInterval>
<exponentialBackoff/>
<retryFailureAction ref="aia-ora-java"/>
<retrySuccessAction ref="aia-ora-java"/>
</retry>
</Action>
<!-- This is an action will cause a replay scope fault-->
<Action id="ora-replay-scope">
<replayScope/>
</Action>
<!-- This is an action will bubble up the fault-->
<Action id="ora-rethrow-fault">
<rethrowFault/>
</Action>
<!-- This is an action will mark the work item to be "pending recovery from console"-->
<Action id="ora-human-intervention">
<humanIntervention/>
</Action>
<!-- This action will cause the instance to terminate-->
<Action id="ora-terminate">
<abort/>
</Action>
<Action id="aia-ora-java">
<javaAction className="oracle.apps.aia.core.eh.CompositeJavaAction" defaultAction="ora-rethrow-fault">
<returnValue value="REPLAY" ref="ora-terminate"/>
<returnValue value="RETHROW" ref="ora-rethrow-fault"/>
<returnValue value="ABORT" ref="ora-terminate"/>
<returnValue value="RETRY" ref="aia-ora-retry"/>
<returnValue value="MANUAL" ref="ora-human-intervention"/>
</javaAction>
</Action>
<Action id="aia-no-action">
<javaAction className="oracle.apps.aia.core.eh.CompositeJavaNoAction" defaultAction="ora-rethrow-fault">
<returnValue value="REPLAY" ref="ora-terminate"/>
<returnValue value="RETHROW" ref="ora-rethrow-fault"/>
<returnValue value="ABORT" ref="ora-terminate"/>
<returnValue value="RETRY" ref="aia-ora-retry"/>
<returnValue value="MANUAL" ref="ora-human-intervention"/>
</javaAction>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
---------------------------------------------------------------------------------------------------------------
FAULT BINDINGS
++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="3.0"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<component faultPolicy="BusinessFault">
<name>MainBPELProcess</name>
</component>
</faultPolicyBindings>
Now you are ready to go and test the custom fault handling using fault policies.
1) Fault BPEL - It will always throw a custom fault
2) Main BPEL - It will invoke the Fault BPEL and capture the custom fault using the fault policy.
FAULT BPEL PROCESS
=====================
1) Create a synchronous BPEL process with name FaultBPELProcess to throw business fault.
2) Customize the file FaultBPELProcess.xsd to add the fault message type.
COMPLEX TYPE
+++++++++++++
<element name="faultarea">
<complexType>
<sequence>
<element name="code" type="string"/>
<element name="summary" type="string"/>
<element name="details" type="string"/>
</sequence>
</complexType>
</element>
3) Customize the file FaultBPELProcess.wsdl to add the fault BusinessFault in the opertions and the fault message type.
a) <wsdl:message name="Fault">
<wsdl:part name="payload" element="client:faultarea"/>
</wsdl:message>
b) Under operations tag added
<wsdl:fault name="BusinessFault" message="client:Fault"/>
4) Now add Throw Activity with namespace 'http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess' and LocalPart 'BusinessFault' and FaultVariable as 'FaultVar'.
5) Deploy the BPEL process to the application server.
MAIN BPEL PROCESS
==================
1) Create BPEL process with name MainBPELProcess to handle the fault thrown by FaultBPELProcess.
2) Customize file MainBPELProcess.xsd to add:
<element name="faultarea">
<complexType>
<sequence>
<element name="code" type="string"/>
<element name="summary" type="string"/>
<element name="details" type="string"/>
</sequence>
</complexType>
</element>
3) Customize file MainBPELProcess.wsdl to add:
a. <wsdl:message name="Fault">
<wsdl:part name="payload" element="client:faultarea"/>
</wsdl:message>
4) Create a partnerlink and make a call to the FaultBPELProcess.
5) Add Invoke Activity to the Main Scope and do the following:
a. Point the invoke activity to the partnerlink used for calling FaultBPELProcess.
b. Create the input and output variables.
c. Click ok to save.
6) Add activity Assign before the invoke activity. Assign the input of the MainBPELProcess to the input variable used in the invoke activity.
7) To the Main Scope add the Catch Activity to catch the Business Fault. Add Reply Activity under the Catch to reply the calling party with the fault variable.
8) Change the composite.xml to add the following:
<property name="oracle.composite.faultPolicyFile">fault-policies.xml</property>
<property name="oracle.composite.faultBindingFile">fault-bindings.xml</property>
9) Deploy the BPEL process to the application server.
FAULT POLICY
============
1) Create fault-bindings.xml.
2) Add the following to it:
<component faultPolicy="BusinessFault">
<name>MainBPELProcess</name>
</component>
3) Create fault-policies.xml.
4) Add the following:
a. faultName, namespace - http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess, the one thrown from the FaultBPELProcess.
b. name - BusinessFault, the local part of the throw activity in FaultBPELProcess.
c. Add the conditions and the actions in the fault policy.
5) Place both the files in MainBPELProcess folder.
================================================================
FAULT POLICY
+++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<faultPolicy version="3.0" id="BusinessFault"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Conditions>
<faultName xmlns:bns="http://xmlns.oracle.com/ErrorHandlingwoAIA/FaultBPEL/FaultBPELProcess"
name="bns:BusinessFault">
<condition>
<!-- Let the component handle this specific business fault -->
<action ref="ora-retry"/>
</condition>
</faultName>
</Conditions>
<Actions>
<!-- This action will attempt 3 retries at increasing intervals of 2, 4, 8 seconds. -->
<Action id="ora-retry">
<retry>
<retryCount>3</retryCount>
<retryInterval>2</retryInterval>
<exponentialBackoff/>
<retryFailureAction ref="aia-ora-java"/>
<retrySuccessAction ref="aia-ora-java"/>
</retry>
</Action>
<!-- This action will attempt 7 retries at increasing intervals of 2, 4, 8, 16, 32, 64, 128 seconds. -->
<Action id="aia-ora-retry">
<retry>
<retryCount>7</retryCount>
<retryInterval>2</retryInterval>
<exponentialBackoff/>
<retryFailureAction ref="aia-ora-java"/>
<retrySuccessAction ref="aia-ora-java"/>
</retry>
</Action>
<!-- This is an action will cause a replay scope fault-->
<Action id="ora-replay-scope">
<replayScope/>
</Action>
<!-- This is an action will bubble up the fault-->
<Action id="ora-rethrow-fault">
<rethrowFault/>
</Action>
<!-- This is an action will mark the work item to be "pending recovery from console"-->
<Action id="ora-human-intervention">
<humanIntervention/>
</Action>
<!-- This action will cause the instance to terminate-->
<Action id="ora-terminate">
<abort/>
</Action>
<Action id="aia-ora-java">
<javaAction className="oracle.apps.aia.core.eh.CompositeJavaAction" defaultAction="ora-rethrow-fault">
<returnValue value="REPLAY" ref="ora-terminate"/>
<returnValue value="RETHROW" ref="ora-rethrow-fault"/>
<returnValue value="ABORT" ref="ora-terminate"/>
<returnValue value="RETRY" ref="aia-ora-retry"/>
<returnValue value="MANUAL" ref="ora-human-intervention"/>
</javaAction>
</Action>
<Action id="aia-no-action">
<javaAction className="oracle.apps.aia.core.eh.CompositeJavaNoAction" defaultAction="ora-rethrow-fault">
<returnValue value="REPLAY" ref="ora-terminate"/>
<returnValue value="RETHROW" ref="ora-rethrow-fault"/>
<returnValue value="ABORT" ref="ora-terminate"/>
<returnValue value="RETRY" ref="aia-ora-retry"/>
<returnValue value="MANUAL" ref="ora-human-intervention"/>
</javaAction>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
---------------------------------------------------------------------------------------------------------------
FAULT BINDINGS
++++++++++++++
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="3.0"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<component faultPolicy="BusinessFault">
<name>MainBPELProcess</name>
</component>
</faultPolicyBindings>
Now you are ready to go and test the custom fault handling using fault policies.
Happy Learning ..!!!!!