SOA 12c - Fault Handling (Creating Fault Policies and Fault Bindings)
Information that you need to know:
Using Fault Handling in a BPEL Process.
Fault handling allows a BPEL process service component to handle error messages or other exceptions returned by outside web services, and to generate error messages in response to business or runtime faults. For more detailed information read the following URLs: https://docs.oracle.com/cloud/latest/soa121300/SOASE/GUID-FE546F09-E9DF-4859-AEF6-A1C7A3F40C75.htm#SOASE478
In SOA Suite 12c we have a wizard to create fault policies and fault binding files.
In this post, we will learn how to add a Fault Policy in an SOA project.
We need to start the JDeveloper IDE.
Click on File menu, then click on New option, followed immediately by Application option.
For Example:Then on the New Gallery window, choose Applications option in General Category, then choose SOA Application item.
For Example:On the Application window, set the next values, and click on next button.
Application Name | FaultHandling |
Directory | C:\JDeveloper\mywork\FaultHandling |
Application Package Prefix |
For example:
On the Project window, set the next values, and click on next button.
Project Name | FaultPolicy |
Directory | C:\JDeveloper\mywork\FaultHandling\FaultPolicy |
For example:
On the Configure SOA settings window, set the next values, and click on finish button.
Standard Composite | Empty Composite |
For example:
After clicking on finish button, the JDeveloper IDE has the next appearance:
Then the next step, we need to select the BPEL Process component, this component is located on the right side, on Components section, when you found this, select it and drag it to Components section on work area.
For Example:On the Create BPEL Process window, set the next values, and click on ok button.
BPEL Specification | BPEL 2.0 Specification |
Name | FaultPolicy |
Namespace | http://xmlns.oracle.com/FaultHandling/FaultPolicy/FaultPolicy |
Directory | C:\JDeveloper\mywork\FaultHandling\FaultPolicy\SOA\BPEL |
Template Type | WebService |
Template | Asynchronous BPEL Process |
Service Name | faultpolicy_client |
Expose as a SOAP Service | Checked |
Delivery | async.persist |
Transaction | async.persist |
Input | {http://xmlns.oracle.com/FaultHandling/FaultPolicy/FaultPolicy}process |
Output | {http://xmlns.oracle.com/FaultHandling/FaultPolicy/FaultPolicy}processResponse |
For example:
Now the next step is add to helloWorld web service and call it, the purpose of this is simulate a remote fault of the web service using our hello world practice.
Note: If you need additional information about how create the hello world project click on the next URL: SOA 12c - HelloWorldIn the imagen below, you can see the WSDL and the XSD files imported from hello world web service.
Once time imported the WSDL, XSD files and all their dependencies, we need to right click on External References, then click on Insert... option, and finally click on SOAP.
Put helloWorld as a name in the Update Reference window, if you prefer you can change the name, but for this exercise we are going to put the value helloWorld.
Now we need drag to add a new Reference, with this action we will have available the Partner Links on .bpel file. For example:
Now we are going to do double click on component: FaultPolicy, then on FaultPolicy.bpel file, we need to select the Invoke activity and drag to work area, just in middle of receiveInput and callBackClient and change the name from Invoke1 to InvokeHelloWorld
For example:Then we need to drag onto a Partner Link to make a Web Service connection. On the Edit Invoke window, set the next values, and click on ok button.
Input Variable | helloWorldIn |
For example:
Now just to send some information to hello world web service we are going to add the assign activity and assign the incoming payload to payload of this web service.
$inputVariable.payload/client:input | $helloWorldIn.payload/ns1:input |
Now we are going to create fault policy file, we are going to right click on the project, then click on New and then click on From Gallery option. Choose Faults option under SOA Tier and select Fault Policy Document.
For example:
We are going to change the Fault Policy field with remoteFault value.
Then on Fault Handlers section we are going to choose remoteFault as a Fault Name as we are going to handle this fault using fault policy file, additional select the default-retry as Default Action.
Next go to Actions tab and put the following values.
ID *: | default-retry |
Retry Count *: | 3 |
Retry Interval *: | 2 |
Exponential Backoff: | Checked |
For example:
Now we will create fault binding file and link this fault policy. Click on "Edit composite policies" in your composite window.
Put the following values to bind your fault policy to fault binding file. Then click on OK button.
Now deploy your composite and test it by generating the remote faults.
Don't forget, you need to simulate the remote failure, you need to shut down your composite to generate the remote failure error, once you get the error, the retry policy should be working.
If your have access to two servers, maybe you can down time one server to simulate the behavior.
Comments
Post a Comment