Introduction
In this blog we see error handling in BPM using Fault Management Framework.Oracle SOA Suite provides a generic fault management framework for handling faults. If a fault occurs during runtime, the framework catches the fault and performs a user-specified action defined in a fault policy file
Similarly, We can design and execute fault policies for Oracle BPM Suite. The fault policies file defines fault conditions and their corresponding fault recovery actions. The fault policy bindings file associates the policies defined in the fault policies file with one of the following:
- Composite with a BPMN process
- Oracle BPMN process service component
- Reference binding component (for example, another BPMN process or a JCA adapter)
- Retry
- Human intervention
- Terminate
- Java code
1. Composite Level Fault Policies
In this demo we will try to insert new employee records into database and check how error framework behaves when exception raised by bpm process.
Employee Business Object
FaultThrower bpm process
Input request mapping
Service mapping
ErrorHandlerProcess bpm process
Create fault-policies.xml file in root folder of project.<?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="0.0.1" id="comp_faultPolicy"
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>
<!-- catches all -->
<faultName>
<condition>
<action ref="Action-Retry"/>
</condition>
</faultName>
</Conditions>
<Actions>
<Action id="Action-Abort">
<abort/>
</Action>
<Action id="Action-Retry">
<retry>
<retryCount>3</retryCount>
<retryInterval>10</retryInterval>
<exponentialBackoff/>
<retryFailureAction ref="Action-human-intervention"/>
</retry>
</Action>
<Action id="Action-human-intervention">
<humanIntervention/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
As mentioned in the fault policy file, if any error occurs, error framework will try three times in 10 second interval.
Create fault_binding.xml in root folder of project.
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<composite faultPolicy="comp_faultPolicy"/>
</faultPolicyBindings>
Configure these files in composite.xml file
I tried to insert dupilcate record in database whcich causes db adapter to throw binding fault in FaultThrower bpm proces. As per fault policy error framework retried to insert same record 3 times and then end the bpm process.
2. Service Component Level Fault Policies
Similarly we can define fault policies for service componentfault-policies.xml
<?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="0.0.1" id="ComponentPolicy"
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>
<!-- catches all -->
<faultName>
<condition>
<action ref="Action-human-intervention"/>
</condition>
</faultName>
</Conditions>
<Actions>
<Action id="Action-Abort">
<abort/>
</Action>
<Action id="Action-Retry">
<retry>
<retryCount>3</retryCount>
<retryInterval>2</retryInterval>
<exponentialBackoff/>
</retry>
</Action>
<Action id="Action-human-intervention">
<humanIntervention/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
fualt-bindings.xml
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<component faultPolicy="ComponentPolicy">
<name>TestProcess</name>
</component>
</faultPolicyBindings>
3. Reference Level Fault Policies
Same way we can define fault policies for reference servicesfault-policies.xml
<?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="0.0.1" id="Policy0"
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>
<!-- catches all -->
<faultName>
<condition>
<action ref="Action-human-intervention"/>
</condition>
</faultName>
</Conditions>
<Actions>
<Action id="Action-human-intervention">
<humanIntervention/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
fault.bindings.xml
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<!-- reference FolderListing is a reference to a file adapter -->
<reference faultPolicy="Policy0">
<name>Services.Externals.WriteFile_Orderdata.reference</name>
</reference>
</faultPolicyBindings>
When a process is called using a service reference, the reference used is not the BPMN process reference, but rather the reference created to call the BPMN process named Services.Externals.TestProcess2Service.reference.
fault-policies.xml
<?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="0.0.1" id="Policy1"
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>
<!-- catches all -->
<faultName>
<condition>
<action ref="Action-human-intervention"/>
</condition>
</faultName>
</Conditions>
<Actions>
<Action id="Action-human-intervention">
<humanIntervention/>
</Action>
</Actions>
</faultPolicy>
</faultPolicies>
fault.bindings.xml
<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
<!-- reference ProcessService1 calls BPMN component Process -->
<reference faultPolicy="Policy1">
<name>Services.Externals.TestProcess2Service.reference</name>
</reference>
</faultPolicyBindings>
Reference service name can be obtained from composite.xml from the wire section
In next blog we will see how to handle System Exception.