Thursday, March 5, 2015

Error Handling in BPM 11G/12C - Fault Management Framework - Part 2

Introduction

In this blog we see error handling in BPM using Fault Management Framework.

Oracle SOA Suite provides a generic fault management framework for handling faults. If a fault occurs during runtime, the framework catches the fault and performs a user-specified action defined in a fault policy file

Similarly, We can design and execute fault policies for Oracle BPM Suite. The fault policies file defines fault conditions and their corresponding fault recovery actions. The fault policy bindings file associates the policies defined in the fault policies file with one of the following:
  • Composite with a BPMN process
  • Oracle BPMN process service component
  • Reference binding component (for example, another BPMN process or a JCA adapter)
The following fault recovery actions are supported in the fault policies file for Oracle BPM Suite:

  • Retry
  • Human intervention
  • Terminate
  • Java code
Here we will cover composite, componet and referenc binding level fault policies.

1. Composite Level Fault Policies


In this demo we will try to insert new employee records into database and check how error framework behaves  when exception raised by bpm process.



Employee Business Object





FaultThrower bpm process

Input request mapping




Service mapping



ErrorHandlerProcess bpm process





Create fault-policies.xml  file in root folder of project.

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <faultPolicy version="0.0.1" id="comp_faultPolicy"
                 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Conditions>
            <!-- catches all -->
            <faultName>
                <condition>
                   <action ref="Action-Retry"/>
                </condition>
            </faultName>
        </Conditions>
        <Actions>
            <Action id="Action-Abort">
                <abort/>
            </Action>
            <Action id="Action-Retry">
                  <retry>
                    <retryCount>3</retryCount>
                    <retryInterval>10</retryInterval>
                    <exponentialBackoff/>
                    <retryFailureAction ref="Action-human-intervention"/>
                </retry>
            </Action>
            <Action id="Action-human-intervention">
                <humanIntervention/>
            </Action>
        </Actions>
     </faultPolicy>
</faultPolicies>


As mentioned in the fault policy file, if any error  occurs, error framework will try three times in 10 second interval.

Create fault_binding.xml  in root folder of project.

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">

    <composite faultPolicy="comp_faultPolicy"/>
</faultPolicyBindings>


Configure these files in composite.xml file




I tried to insert dupilcate record in database whcich causes db adapter  to throw binding fault in FaultThrower bpm proces. As per fault policy error framework retried to insert same record 3 times and then end the bpm process.






2.  Service Component Level Fault Policies

Similarly we can define fault policies for service component




fault-policies.xml

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <faultPolicy version="0.0.1" id="
ComponentPolicy"
                 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Conditions>
        <!-- catches all -->
        <faultName>
            <condition>
               <action ref="Action-human-intervention"/>
            </condition>
        </faultName>
    </Conditions>
    <Actions>
        <Action id="Action-Abort">
            <abort/>
        </Action>
        <Action id="Action-Retry">
              <retry>
                <retryCount>3</retryCount>
                <retryInterval>2</retryInterval>
                <exponentialBackoff/>
            </retry>
        </Action>
        <Action id="Action-human-intervention">
            <humanIntervention/>
        </Action>
    </Actions>
  </faultPolicy>
</faultPolicies>


fualt-bindings.xml


<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
    <component faultPolicy="ComponentPolicy">
        <name>TestProcess</name>
    </component>

</faultPolicyBindings>


3. Reference Level Fault Policies

Same way we can define fault policies for reference services



fault-policies.xml

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <faultPolicy version="0.0.1" id="Policy0"
                 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Conditions>
            <!-- catches all -->
            <faultName>
                <condition>
                  <action ref="Action-human-intervention"/>
                </condition>
            </faultName>
        </Conditions>
        <Actions>
            <Action id="Action-human-intervention">
                <humanIntervention/>
            </Action>
        </Actions>
     </faultPolicy>
</faultPolicies>


fault.bindings.xml

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">
 <!-- reference FolderListing is a reference to a file adapter -->
    <reference faultPolicy="Policy0">
        <name>Services.Externals.WriteFile_Orderdata.reference</name>
    </reference>

</faultPolicyBindings>


When a process is called using a service reference, the reference used is not the BPMN process reference, but rather the reference created to call the BPMN process named Services.Externals.TestProcess2Service.reference.



 fault-policies.xml

 <?xml version="1.0" encoding="UTF-8"?>
<faultPolicies xmlns="http://schemas.oracle.com/bpel/faultpolicy"
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <faultPolicy version="0.0.1" id="Policy1"
                 xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
                 xmlns:xs="http://www.w3.org/2001/XMLSchema"
                 xmlns="http://schemas.oracle.com/bpel/faultpolicy"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
        <Conditions>
            <!-- catches all -->
            <faultName>
                <condition>
                  <action ref="Action-human-intervention"/>
                </condition>
            </faultName>
        </Conditions>
        <Actions>
            <Action id="Action-human-intervention">
                <humanIntervention/>
            </Action>
        </Actions>
     </faultPolicy>
</faultPolicies>



 fault.bindings.xml

<?xml version="1.0" encoding="UTF-8"?>
<faultPolicyBindings version="2.0.1" xmlns="http://schemas.oracle.com/bpel/faultpolicy">

    <!-- reference ProcessService1 calls BPMN component Process -->
    <reference faultPolicy="Policy1">
        <name>Services.Externals.TestProcess2Service.reference</name>
    </reference>

</faultPolicyBindings>


Reference service name can be obtained from composite.xml from the  wire section




In next blog we will see how to handle  System Exception.

6 comments:

  1. Please share the system Exception handling in BPM

    ReplyDelete
  2. one of the best explanation, keep sharing :)

    ReplyDelete
  3. Thank you for your articles that you have shared with us. Hopefully you can give the article a good benefit to us. BPM en la nube

    ReplyDelete
  4. Iam so thrilled because of finding your alluring website here.Actually i was searching for Oracle BPM.Your blog is so astounding and informative too..Iam very happy to find such a creative blog. Iam also find another one by mistake while am searching the same topicOracle SQL.Thank you soo much..

    ReplyDelete
  5. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Same as your blog i found another one Oracle BPM .Actually I was looking for the same information on internet for Oracle BPM and came across your blog. I am impressed by the information that you have on this blog. Thanks once more for all the details.

    ReplyDelete
  6. How to play slot machines at Mohegan Sun - JTM Hub
    You can't do all those 삼척 출장샵 things like slot machines 충주 출장샵 in 전라북도 출장마사지 an indoor bathroom. The casino 용인 출장안마 floor at Mohegan Sun offers 1,600 slot machines, 70 경기도 출장샵 table games,

    ReplyDelete