Monday, 17 October 2011

SOA 11g Tutorial: Policy Based Fault Handling

Fault Policy Overview

* Since
* Catches all faults from an invoke activity (both run time and business faults)
* Overrides all catch activities in BPEL process.
* A fault policy defines conditions and their corresponding fault recovery actions.
* Fault policies are defined in multiple files under directory:
- bpel\domains\default\config\fault-policies
* XSD files are:
- bpel\system\xmllib\fault-policy.xsd
- bpel\system\xmllib\fault-policy-binding.xsd
* A fault policy can be associated at the following levels:
- Partner link
- Port type
- Process level via bpel.xml
- Domain level via fault-bindings.xml
* Fault policy binding order:
-> bpel.xml: partner link -> port type -> process
-> domain: partner link -> port type -> process
-> Catch blocks defined in bpel diagram.

SOA Fault Types

Business Faults

* Programmer defined.
* Defined in WSDL.

Runtime Faults

* Predefined, e.g.
- remoteFault
- bindingFault
* Infrastructure faults, e.g.
- Service down
- Network outage
* Data format errors

Design a Fault Policy

Create a Fault Policy File

* Create policy file (e.g. my-policies.xml) in bpel\domains\domain_name\config\fault-policies directory

Define conditions

* Conditions are based on faultName. e.g.
* Multiple conditions are allowed for a single faultName
- if so, conditions are evaluated sequentially
    <action ref="ora-terminate"/>
    <action ref="ora-java"/>
* Each condition has
- one test section which is an XPath expression against fault variable
- one action section which references to the action defined in the same file
    <action ref="ora-terminate"/>
- No test condition catches all
  <action ref="ora-rethrow"/>
- No faultName catches all faults
<faultName > . . . </faultName>

Define actions

* See examples below.

Fault Policy Examples

* Conditions
  <!-- when bpelx:remoteFault, retry -->
      <action ref="ora-retry"/>
  <!-- when bpelx:bindingFault, rethrow fault -->
      <action ref="ora-rethrow-fault"/>
* Actions
<!-- retry Action -->
<Action id="ora-retry">
    <retryFailureAction ref="ora-terminate"/>
<!-- replayScope Action -->
<Action id="ora-replay-scope">
<!-- rethrowFault Action -->
<Action id="ora-rethrow-fault">
<!-- humanIntervention Action -->
<Action id="ora-human-intervention">
<!-- abort Action -->
<Action id="ora-terminate">
<!-- Custom Java Action -->
<Action id="ora-java">
  <javaAction className="mypackage.myClass"
    <returnValue value="R_TRM"
    <returnValue value="R_THRW"
- Java class must implement IFaultRecoveryJavaClass interface
public interface IFaultRecoveryJavaClass {
  public void handleRetrySuccess(IFaultRecoveryContext ctx );
  public String handleBPELFault(IFaultRecoveryContext ctx );

Associate a Fault Policy

* Process level
- Configured in bpel.xml file.
- Only one fault policy can be bound to a process, port type, or partner link.
- Multiple port types or partner links can be bound to a single fault policy.
  <!-- Fault on any plink/port type not specified -->
  <!-- below uses policy BillingFaults -->
<process faultPolicy="BillingFaults"/>
<partnerLink xmlns:credit="" faultPolicy="CRM_
      <!-- Fault on these 2 plink will use policy CRM_ServiceFaults -->
    <!----Fault on these 2 port types uses policy CRM_ServiceFaults -->
<portType xmlns:united="">
<partnerLink faultPolicy="myOtherFaults">
    <!-- Fault on this plink uses policy myOtherFaults -->
* Domain level
- Configured in OracleAS_2\bpel\domains\default\config\fault-bindings.xml file.
  <!-- all processes in this domain use DefaultPolicy -->
<process faultPolicy="DefaultPolicy"/>
<partnerLink faultPolicy="DefaultPolicy">
    <!-- all invoke faults at partner link creditRatingService use DefaultPolicy -->
<partnerLink faultPolicy="DefaultPolicy">
    <!-- all invoke faults at specific port type use DefaultPolicy -->

Human Intervention in Oracle BPEL Control

* Login BPEL console
* Click Activities tab
* Seach activities based on states
- All States: Displays all activities, regardless of their state.
- Open: Displays only open activities.
- Completed: Displays only completed activities.
- Cancelled: Displays only cancelled activities.
- Stale: Displays only stale activities.
- Pending: Displays only pending activities.
* Click the faulted activity
* Optionally change the variable values
* Select action to take
- Retry: Retries the activity with an option to provide a retry success action.
- Abort: Terminates the process instance of the faulted activity.
- Rethrow: Rethrows the exception and allows the BPEL fault handlers (catch branches) to handle the fault.
- Replay: Replays the scope in which the fault occurred.
- Continue: Skips the activity. The framework assumes the activity completed with no fault.
* Click the Recover button.

No comments:

Post a Comment