Sunday, March 14, 2010

Fault Management Framework in SOA Suite

A fault management framework in SOA suite works much like handling exceptions in java.

It is done by defining fault policies.A fault policy thus defines a fault condition and also provides the action that has to be performed in case of fault condition.

Fault policies are provided by default with the istallation and can be found in the following location

SOA_HOME\bpel\domains\domain_name\config\fault-policies\

Default-policy.xml


Fault policy can be defined at following levels Partner link,Port type,Process and Domain level.It is the work of a fault binding file to associate the fault policy with the partnerlink,port type,process and Domain.

For the domain level the fault binding policy is located at

SOA_HOME\bpel\domains\domain_name\config\fault-bindings.xml

For process level the fault binding policy is defined at bpel.xml

The order of fault-binding is

1>Partner link binding in bpel.xml
2>Port type binding in bpel.xml
3>Process binding in bpel.xml
4>Partner link binding in fault-binding.xml
SOA_HOME\bpel\domains\domain_name\config\fault-bindings.xml
5>Port type binding in fault-binding.xml
6>Process binding in fault-binding.xml

The fault-binding policy has a precedence over catch blocks designed in process so the engine first looks for the fault binding policy and if it doesn't get a match then it enters the catch block.

Configuration file for designing fault-binding.

In order to design fault-binding you will be using 3 configuration files essentially.

The first one is fault-policy.xml

this is the file where in we define the fault condition and the action that has to be performed for the error condition.


so it should contain values

<faultName xmlns:bpelx="http://schemas.oracle.com/bpel/extension" name="bpelx:remoteFault">
<condition>
<action ref="ora-retry"/>
</condition>
</faultName>

here we are defining the condition that whenever a remoteFault occurs you have to refer to the ora-retry

So again we need to define the action

that will again be done in this way

<Action id="ora-retry">
<retry>
<retryCount>8</retryCount>
<retryInterval>2</retryInterval>
<retryFailureAction ref="ora-terminate"/>
<exponentialBackoff/>
</retry>
</Action>

this action template suggest that whenever there is a remote fault the you have to perform the ora-retry action which sugggest to retry the feature again.It will retry for 8 times with a time interval of 2 seconds and then again it will refere to ora-terminate which will end the process.

the template ora-retry,ora-terminate are predefined template.You can provide fault-policy name any name as per your requirement but it must follow the xsd file

fault-policy.xsd schema
available in the SOA_HOME\bpel\system\xmllib

So you need to change the fault-policy.xsd for changing the fault-policy name.

SOA suite provides a default fault policy.xml file located at

SOA_HOME\bpel\domains\default\config\fault-policies

it is called as DefaultPolicy.xml

now we have designed our default policy the next things is to design the binding that it to associate the falut-policy with the partnerlink,process or port type as per business requirement.

This can be done by one more file called as fault-binding.xml

it is located at

SOA_HOME\bpel\domains\default\config

A quick review of this file will show how to design your fault-binding.

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1"
xmlns="http://schemas.oracle.com/bpel/faultpolicy"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- Enabling this will cause all processes in this domain to use this
fault policy
<process faultPolicy="DefaultPolicy"/>
-->
<!-- DefaultPolicy is defined in ./fault-policies/DefaultPolicy.xml -->
<partnerLink faultPolicy="DefaultPolicy">
<!-- Enabling this will cause all invoke faults at partner link
name of "creditRatingService" to use fault policy with
id id = DefaultPolicy
<name>creditRatingService</name>
-->
<!-- all invoke faults at partner link below port type use fault policy
with id = DefaultPolicy
<portType xmlns:demo="http://xmlns.oracle.com/pcbpel/adapter/db/insert/">demo:port</portType>-->
</partnerLink>
</faultPolicyBindings>


As you can see here examples have been given if you want to bind it to at domain-level,process level,partnerlink level or port level.

or if you don't want to use the fault-binding.xml you can optionally add the binding in bpel.xml


<faultPolicyBindings>
<process faultPolicy="BillingFaults"/>
<!-----below uses policy BillingFaults--->
<partnerLink xmlns:demo="http://services.otn.com" faultPolicy="DefaultPolicy">
<name>ServiceName</name>
</partnerLink>
</faultPolicyBindings>

Here i have made an entry for partnerlink only you can add as per your requirement.

Save the changes you need to restart your server in order to make these changes take effect.

Restart and check if the fault policy works for you.

fault-policies.xml loads at startup and once you made the change u need to restart ur server

No comments: