Oracle BPEL Fault Policy Framework handling custom business faults

From the Oracle forum and from the comments on my article about Oracle BPEL Fault Policy Management i get a lot of questions about how to let the framework handle my own custom defined ‘business faults’.
In certain situations the default set of faults defined by Oracle aren’t suited enough and you need to define your own faults.
If we look into the examples which got supplied by Oracle we can see an example over here. In this example they defined their own NegativeCredit-fault.

The Oracle BPEL Fault Policy Framework by default only handles the faults which are getting returned on an invoke-activity.
So we have our own custom fault and the knowledge we can only let this fault getting catched by the framework by use of an invoke.
So we need atleast for this testscenario 2 bpel processes. One mainprocess which calls a subprocess, and this subprocess will throw the custom business fault.
This fault will get propogated back to the mainprocess and in here we will be able to let the framework handle the fault.

bpel-invoke

BPEL Processes

Mainprocess

mainprocess

Subprocess
subprocess

Just a simple invoke of the subprocess from the mainprocess. The subprocess with throw a fault, and this fault will be catched in the mainprocess.
throwThe fault to be thrown

From the console start the mainprocess and wait till it comes back with a fault messageinvoke-faultedClick the activity to see the thrown fault

[2009/02/13 16:24:41]
"{http://nl.iteye/integration/faults/business}BusinessFault" has been thrown. 

<BusinessFault xmlns="http://nl.iteye/integration/faults/business">
<part name="payload">
    <BusinessFault xmlns="http://nl.iteye/integration/faults/business">
      <FaultCode>999</FaultCode>
      <FaultMessage>Something went wrong!</FaultMessage>
    </BusinessFault>
  </part>
</BusinessFault>

Ok nice!
So the custom fault we defined in the subprocess reaches the mainprocess.
Now we need to config the fault policy framework so it will get active on our custom business fault.
From the fault we pasted above we need the faultname (BusinessFault) and the namespace (http://nl.iteye/integration/faults/business).

Edit /bpel/domains/default/config/fault-policies/DefaultPolicy.xml and add the next fault :

   <faultName xmlns:flt="http://nl.iteye/integration/faults/business" name="flt:BusinessFault">
            <condition>
                    <action ref="ora-human-intervention"/>
            </condition>
   </faultName>

For testing we will just let this fault getting handled by human-intervention.
Now restart the components

opmnctl stopall
opmnctl startall

Now start the mainprocess again and wait till it fails.

invoke-faulted-frameworkIt looks like the framework got active (activity yellow marked) on our custom business fault.
invoke-faulted-audit

Go to the activities-tab

list-activities
And click the activity which faulted.

edit-activity
Now we can edit some of the values and let the subprocess get re-invoked.

So, at this moment we’re able to throw our custom business faults and let them getting catched by the framework. Since the fault is only getting catched on the invoke of a partnerlink, we aren’t able to let our custom business fault getting throwned to the process in which we maybe want do something with the data for which we actually throwed the custom business fault. So maybe we want to stay in the subprocess and somehow get the custome business fault thrown inhere, let the framework catch it and update the values of this subprocess with new values an re-execute the subprocess.

The next solution will get this done.
The mainprocess won’t get changed but in the subprocess we will invoke a new process called AllBusinessFaults.

New subprocess 2
subprocess2

AllBusinessFaults
all-business-faults

The AllBusinessFaults will throw the custom business fault we ‘request’ back on the invoke in this subprocess. Now it wil get catched by the framework and we will be able to change the values of the subprocess instead of the mainprocess.

list-activities2

By using the AllBusinessFaults bpel service like a sort of composite service, we can add the custom business faults in it and throw the one we would like to get thrown. This will work if the collection of custom business faults isn’t that big. I’m sure there will be better solutions for this, but for the scenario i wanted to describe inhere it was good enough for me.

Question
In the examples i provided i don’t use the fault-part of a synchronous invoke to propegate the soap-fault back to the caller, i just throw the fault. The bpel engine itself throws the fault back to the first-level. Whats best practice on this one ?

Sources
BPEL Sources (First part of article with mainprocess/subprocess)
BPEL Sources (Second part of article with mainprocess/subprocess/allbusinessfaults)

Resources
Oracle BPEL 10.1.3.3 Fault Policy Management

Advertisements

About Eric Elzinga
Eric Elzinga I'm an integration consultant located in The Netherlands. Mainly doing projects based on Oracle integration stacks (Oracle SOA Suite/Oracle Service Bus (OSB)), Java development, and opensource integration products.

10 Responses to Oracle BPEL Fault Policy Framework handling custom business faults

  1. Pingback: IT-eye » Oracle BPEL Fault Policy Framework handling custom business faults

  2. Ravindranath says:

    Hi ,

    Good one. But i wasn’t able to download the Bpel Sources. Is there any chance that I could have them.

    Thanks in advance.

  3. Eric Elzinga says:

    Hi Ravindranath,

    I updated the download links.

    Good luck!

  4. Amit says:

    Wow, very nicely explained..i am raring to go and try this out.

  5. The best information i have found exactly here. Keep going Thank you

  6. Borut says:

    I did not get caller process receiving back thrown fault from called process, but got instead of it timeout error. I am using BPEL 10.1.3.3 on WebLogic and fault policies works ok on ‘normal’ invoke errors.

    Found some info on participate that if added to BPEL descriptor of caller process, under section of relevant partner link binding, would insure that errors are propagated between two BPEL processes, but didn’t work. And your samples do not have this parameter in use either.

    Both of BPEL processes are with closed.faulted status.

    Do you have some suggestions on why thrown faults when there is no catch block do not get propagated to caller even in the case that called process is synchronous?

    Thanks in advance

  7. Pingback: Oracle BPEL Fault Policy Framework handling custom business faults | Oracle .. Java .. OpenSource .. SOA

  8. Gustavo says:

    Hi,

    I can not create my own fault message.
    I have received:

    fpre:technicalFault
    ….

    But I would like to received inside of SOAP Body message just my fault as it is in tag .I don’t wanna faultcode, faultstring, faultactor and detail tags.

    Could you please help me?

    • Gustavo says:

      Actually I have received:

      0


      oracle.fabric.common.FabricInvocationException

      null


      null

      but I would like my custom fault message

  9. khaja says:

    Hi Elzinga,

    Really its a good explanation could u please tell how can i catch this fault in OSB.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: