Showing posts with label Fault Policy Document in SOA 12c. Show all posts
Showing posts with label Fault Policy Document in SOA 12c. Show all posts

Thursday, July 16, 2020

Fault Policy Document in SOA 12c

Hi, Welcome to my blog! In this post, I'm going to show you how we use fault policy document in SOA 12c. Here, I will use FPD for remote fault.

First, we will be creating two projects. First project will take input and give output. We'll create another project and call first project in the second project. Then we'll purposely shut down first composite and define a fault policy in second composite to handle the fault using fault policy document. So lets get started.

1. Create a sample project.





Drag and drop a BPEL with Synchronous interaction.





Assign input variable to output variable using Assign activity. Concatenate 'Hello' to input variable when assigning it to output or leave it as it is to get the exact input as output.





Now, deploy your composite and test it by giving some value in input payload. If you are new to SOA and want above composite in detail, check out my Hello World example.





You'll see output as below:




So, first SOA project is working as expected. Copy the WSDL URL of this composite.


2. Create another SOA Project as below.





Drag and drop a SOAP Adapter to the External Services swim lane. Paste the copied URL into the WSDL URL and click OK.





Drag and drop a BPEL and select the Template as Synchronous.





Wire the BPEL to SOAP reference.





Edit the BPEL and add an Invoke activity in between Receive and Reply. Wire it to SOAP and create Input, Output variables.





Drag and drop two assign activities to assign input to Invoke input and Invoke output to output variable.









Your final composite should look like this:





Now, deploy and test this composite.






You'll get output as below. Here, second composite is invoking the first composite.




Now, shut down the first composite.





Test the CallSampleHello composite. You'll get an invocation error which is a remote fault.





You can see the Recovery status as Nonrecoverable.




We will handle this remote fault using Fault Policy Document.


3. Create a fault policy document in second project. 
Right click on Project>New>From Gallery>Fault Policy Document>Select and Click OK.





Select the Fault Name as Remote Fault and give the Default action as Default Retry.






You can also set the number of retries it has to attempt.




As soon as you create this fault policy document, you'll see fault-policies.xml it in your project artifacts on the left pane.


Now, bind this document to your composite. Go to the Composite of CallSampleHello or whichever is in your case. Click on the highlighted icon to bind the fault policy.





Give your fault policy name under Policy. Click OK.





You'll now see fault-bindings.xml file in your artifacts. 

Save All and deploy your composite. Go to flow instances and Click on your composite. You can see that it has attempted 3 retries.






Note: Sometimes, when you bind the fault policy document to your composite, it takes fault-bindings.xml for both Policy and Bindings file. In that case, click on your composite.




Go to Source tab




If you can check the Property values, you see fault-bindings.xml for both Policy and Bindings file. (If everything is correct, don't change anything)




You need to change it as below. Set "oracle.composite.faultPolicyFile" property value to "fault-policies.xml" when you see it as "fault-bindings.xml".




Happy learning. Cheers!!

Featured Posts

Sample Real Time Assignment in Oracle SOA