Wednesday 14 March 2012

FAULT POLICY IN SOA 11G


Fault Policy Overview


* Since 10.1.3.3
* Catches all faults from an invoke activity (both run time and business faults)
* Important: 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.
 
<faultName
  xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
  name="bpelx:remoteFault">
 
* Multiple conditions are allowed for a single faultName
- if so, conditions are evaluated sequentially
 
  <condition>
    <test>$fault.code/code="WSDLReadingError"</test>
    <action ref="ora-terminate"/>
  </condition>
  <condition>
    <action ref="ora-java"/>
  </condition>
 
* Each condition has
- one test section which is an XPath expression against fault variable
 
    <test>$fault.code/code="WSDLReadingError"</test>
 
- one action section which references to the action defined in the same file
 
    <action ref="ora-terminate"/>
 
- No test condition catches all
 
<condition>
  <action ref="ora-rethrow"/>
</condition>
 
- No faultName catches all faults
 
<faultName > . . . </faultName>
 

Define actions

* See examples below.

Fault Policy Examples

* Conditions
 
<Conditions>
  <!-- when bpelx:remoteFault, retry -->
  <faultName
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:remoteFault">
    <condition>
      <action ref="ora-retry"/>
    </condition>
  </faultName>
 
  <!-- when bpelx:bindingFault, rethrow fault -->
  <faultName
    xmlns:bpelx="http://schemas.oracle.com/bpel/extension"
    name="bpelx:bindingFault">
    <condition>
      <action ref="ora-rethrow-fault"/>
    </condition>
  </faultName>
</Conditions>
 
* Actions
 
<!-- retry Action -->
<Action id="ora-retry">
  <retry>
    <retryCount>8</retryCount>
    <retryInterval>2</retryInterval>
    <retryFailureAction ref="ora-terminate"/>
    <exponentialBackoff/>
  </retry>
</Action>
 
<!-- replayScope Action -->
<Action id="ora-replay-scope">
  <replayScope/>
</Action>
 
<!-- rethrowFault Action -->
<Action id="ora-rethrow-fault">
  <rethrowFault/>
</Action>
 
<!-- humanIntervention Action -->
<Action id="ora-human-intervention">
  <humanIntervention/>
</Action>
 
<!-- abort Action -->
<Action id="ora-terminate">
  <abort/>
</Action>
 
<!-- Custom Java Action -->
<Action id="ora-java">
  <javaAction className="mypackage.myClass"
    defaultAction="ora-terminate"
    propertySet="propSet1">
    <returnValue value="R_TRM"
      ref="ora-terminate"/>
    <returnValue value="R_THRW"
      ref="ora-rethrow-fault"/>
  </javaAction>
</Action>
- 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.
 
<faultPolicyBindings>
  <!-- Fault on any plink/port type not specified -->
  <!-- below uses policy BillingFaults -->
<process faultPolicy="BillingFaults"/>
<partnerLink xmlns:credit="http://services.otn.com" faultPolicy="CRM_
    ServiceFaults">
      <!-- Fault on these 2 plink will use policy CRM_ServiceFaults -->
      <name>UnitedLoanService</name>
      <name>StarLoanService</name>
 
    <!----Fault on these 2 port types uses policy CRM_ServiceFaults -->
<portType>credit:CreditRatingService</portType>
<portType xmlns:united="http://services.uninted.com/loan">
    united:UnitedLoanService</portType>
  </partnerLink>
<partnerLink faultPolicy="myOtherFaults">
    <!-- Fault on this plink uses policy myOtherFaults -->
    <name>AnotherPartnerLink</name>
  </partnerLink>
</faultPolicyBindings>
 
* 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 -->
    <name>creditRatingService</name>
  </partnerLink>
 
 
<partnerLink faultPolicy="DefaultPolicy">
    <!-- all invoke faults at specific port type use DefaultPolicy -->
<portType
      xmlns:db="http://xmlns.oracle.com/pcbpel/adapter/db/insert/">db:insert_plt</portType>
  </partnerLink>
 

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

xslt padding with characters call template for left pad and right pad

  Could a call-template be written that took two parameters ?   a string, and a   number) return the string with empty spaces appended t...