Powered By Blogger

Search This Blog

Showing posts with label BPEL. Show all posts
Showing posts with label BPEL. Show all posts

Tuesday, April 5, 2011

Java Embedding

“I have a Customer Entity Bean that allows me to retrieve a SSN based on an email id. How can I invoke that bean from within my BPEL process?”


There are 3 solutions to this problem: • Wrapping the Java component into a full blown web service using JDeveloper or Axis • Using the WSIF Java Binding • Using the Java BPEL exec extension ()


1. BPEL Extension which allows developers to embed a snippet of Java code within a BPEL process 2. When the is reached, the server executes the snippet of Java code (within its JTA transaction context) 3. A set of built-in methods allow developers to read and update scope variables, instance metadata and audit trail 4. XML Façade can be used to simplify DOM manipulation 5. Java exceptions are converted into BPEL faults and bubbled into BPEL process 6. The snippet can propagate its JTA transaction to session and entity beans that it calls


----------------------------------------------------------------------------


BPEL Concepts Built-in Methods Java Embedding Object lookup( String name ) Locator getLocator( ) long getInstanceId( ) String setTitle( String title ) / String getTitle() String setStatus( String status ) / String getStatus() void setIndex( int i, String value ) / String getIndex( int i ) void setPriority( int priority ) / int getPriority() void setCreator( String creator ) / String getCreator() void setCustomKey( String customKey ) / String getCustomKey() void setMetadata( String metadata ) / String getMetadata () String getPreference( String key ) void addAuditTrailEntry(String message, Object detail) void addAuditTrailEntry(Throwable t) File getContentFile( String rPath ) Object getVariableData(String name) throws BPELFault Object getVariableData(String name, String partOrQuery) throws BPELFault Object getVariableData(String name, String part, String query) void setVariableData(String name, Object value) void setVariableData(String name, String part, Object value) void setVariableData(String name, String part, String query, Object value)


What Did We Learn? • There are 3 ways to integrate an existing Java component into a BPEL process: 1) wrapping that component in a SOAP service, 2) using a binding framework such as WSIF or 3) inline a code snippet using • The snippet is executed within the transaction context of the BPEL server. You can propagate that transaction to your own session and entity beans • A set of built-in methods allow the snippet to read and update variables, change instance metadata and throw faults • XML Façade can be used within a snippet to simplify DOM manipulation




Monday, April 4, 2011

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

01[2009/02/13 16:24:41]
02"{http://nl.iteye/integration/faults/business}BusinessFault" has been thrown.
03
05<part name="payload">
07 <FaultCode>999FaultCode>
08 <FaultMessage>Something went wrong!FaultMessage>
09 BusinessFault>
10 part>
11BusinessFault>

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 :

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

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.