Tuesday, November 23, 2010

Fault Handling in SOA 11g

The configuration of the fault management Framework for a SCA component has been made more flexible than it was in 10g. We can configure fault policies not only on composite level but also on component level. This enables us to configure retry policies not only on an error type and filter but also on specific components. To do this you just need two files:
You have to enable the fault policy by adding the files to your sca component, or you can add a reference in the sca component to hem, for example when they are placed in the mds.
fault-bindings.xml
Examples of fault-bindings.xml files can be found in oracle’s documentations:
fault-policies.xml
An detailed fault-policies.xml file can be found here.
Mediator
The Fault Management Framework is only applicable for mediators that processes their rules parallel, see documentation Fault Policies Mediator. If an error is matched in the fault policy an possible predefined fault action in the mediator will be ignored. Be aware of this when you are defining your fault policies and error handling.
Example
I have made a simple sca component to show the working of the framework. This sca component has two components {BPEL and Mediator} which are exposed as services to the outside world.

CompositeOverview
They will pass the message to a BPEL that throws a remote exception so we can test the working of the configured fault policies and bindings. In this case a simple available exception but in real it could be an custom defined Business exception to trigger the fault handling. We will see also the way to recover an BPEL instance and a Mediator instance.
RemoteExceptionBPEL
The fault-policies.xml that’s configured in this project
FaultPoliciesXml
This fault-bindings.xml that’s configured in this project
FaultBindingsXml
If you would like to define on component level the fault policies the fault-bindings.xml would look like this
FaultPoliciesXmlComponent
Testing the composite
We deploy the composite and test if all the instances are cached by the defined fault policy.
Mediator Routing
First i invoked the service that’s connected to the mediator routing.
InvokeMediatorRouting
De defined fault policy works fine because the instance is been marked recoverable. By clicking on the link ‘Recoverable’ you get a popup where you can modify the payload (if needed) and select a recover action.InvokeMediatorRoutingRecover
BPELRouting
Second i tested the service that’s connected to the BPELRouting component.
InvokeBPELRouting
We have here also the same link to recover this instance.
InvokeBPELRoutingRecover
That’s the end of a simple example to get started with the Fault Management Framework.

Setting and Getting Preferences in Oracle SOA Suite 11g

In SOA 11g, to define configuration properties and values for a BPEL process, add the properties under the service component section of the composite.xml file.


1<component name="BPELProcess1">
2  <implementation.bpel src="BPELProcess1.bpel"/>
3  <property name="bpel.preference.myPref">MyCurrentValueproperty>
4component>

Now we can use the function ora:getPreference(myPref) in our bpel process to retrieve the value of the preference. 
Watch the naming convention. It expects it to start with “bpel.preference”.


Create the composite application and deploy it. We only added an assign to the flow which will get assign the value of the preference to the outputVariable. Run the bpel and check if the value of ‘MyCurrentValue’ is in the outputVariable.
current_value
In Oracle SOA Suite 10g we could change the value of the preferences from the bpel console. In Oracle SOA Suite 11g things changed a but, we got a new fancy console to manage all the components. To change to values from the prefences go to the ‘Enterprise Manager’ (http://localhost:7001/em).
On the left go to : Farm_soa_domain > Weblogic Domain > soa_domain > right mouseclick and select ‘System MBean Browser’. mbean Navigate to Application Defined MBeans > oracle.soa.config > Server : soa_server1 > SCAComposite > your_project > SCAComposite.SCAComponent > your bpel_process. Select the Attribute ‘Properties’. properties Change the value of our preference and click apply. preference
Run the bpel again to see if the new value got used in the process. new_value