Fault Policies in Oracle SOA 12c.
Oracle has come up with a new policy editor in the release 12c. First to cover the topic we are trying to explain the fault policies.
First to cover requirement of the fault policies, In SOA process if everything goes fine, no issue :-), but there could be some issue in the process, which either be enforced by design like when credit card validation failed, process will throw and error, or may be a service which we are trying to access is down.
Now for the some of the scenarios, we may want to write an alternate path, if some issue occurred. Like if the service is down we may want to retry the service post 10 min and want to retry 3 times before declaring process got error out.
Hence we can divide fault into to two categories either business fault of system fault. Business faults are normally been divide into two categories
1. Business Fault
2. System Fault
Now requirement of fault policies, if we want to consume a service in 2-3 processes and want same behavior then better to write a fault policy also above logic, where we want to retry 3 times can be write just configurations.
In the example below we have created two processes. One process can generate fault if customer number is not from IN0001, IN0002, IN0003 and IN0004.
Now download the application from the link. open in 12C jdev.
First please analyze CustomerValidationProcess.wsdl. You can see that we have introduce three message type one is of input and other is of ouput and last one is fault type. Once customer is not from the list above it throw the invalid customer fault.
Fault can be of multiple types and you can defined different message type for the fault, or can keep it uniform.
If you can be download and open the wsdl file CustomerValidationProcess.wsdl you can see the above structure of the wsdl, where file is clearly stating fault and other messages for input and output.
Now the main process of our is calling this process and when ever its throwing error, we want to retry three times and then only want to mark this process as error.
fault-policies.xml
This is been written in the fault policy file. It can simple be created by Jdev File -> new and fault policy document.
In 12c we have an editor by which we can modify the fault policy document visually, create a new fault policy, like for the above action we created a new fault poilicy policyRetryOnFault, and in this we have configure the fault name and also, what will be default action for it.
fault-bindings.xml
Once done we need one more file which fault-bindings.xml. This file is still not available for editor hence now we need to create an xml document and create it.
In this file you need to tell soa which policy to apply on which level, in this example we have applied policy over the entire composite hence we need following instruction in file.
<?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">
<composite faultPolicy="orderProcessingPolicy"/>
<composite faultPolicy="policyRetryOnFault"/>
</faultPolicyBindings>
Run and test
1. Deployment
In this example, we have two composites which are been used, hence first deploy Order processingSupportingService and then Order processing fault policy.
2. Test
Use the Error payload given in the payload folder to test the composite, If you dont know how to test use our earlier blogs over it.
Once done see the flow trace you can see this post one error service is been tried three more times and then it finally exit the process.
Now you can play with fault-policies.xml
1. Change the retry count
2. Change interval
Redeploy and notice impact of the configuration changes to the process.
Hope you like the blogs, know us your comments about the blogs.
thank you sir for great explanation
ReplyDeleteCan you please let me know if you have tried with test condition? Whatever the syntax I give in fault policy it’s not working. Only the default condition is working. Looks like the xpath is wrong. Tried as per the oracle document even for remote fault but it’s not working. Can you please tell me if you know the working syntax for adding test condition.
ReplyDelete