Sunday, 25 September 2011

Oracle Fusion, BPEL and coordination of master- and detail processes

Because of a little illness Lucas was a bit faster with the publish of his article :) but i decided to still post it on my blog.
In the new Fusion 11g, Oracle added a new extension to the bpel language for the coordination of master- and detail processes.
With this add on it is possible to relate a master process with his detail processes and give signals to each other when to start and when parts are finished.

Let’s start with building something
We created a new composite application and added 3 bpel processes to it.
The first process is the master process and this one will invoke 2 detail processes.
The idea is to let both detail process only get started when they receive a ‘signal’ from the master processes. If they receive it,
they’ll execute their own logic and when either finished or at some point they want to communicate back to the master process, they give a ‘signal’ back.
In the master process, after the the receive add the first signal
1<bpelx:signal name="doDetail1" label="doDetail1" to="details"/>
This will give the first detail process a signal so it will be able to receive
Now we need to invoke the first detail process
1<invoke name="invokeDetail"
2        inputVariable="invokeDetail_process_InputVariable"
3        partnerLink="MyDetail.mydetail_client" portType="ns1:MyDetail"
4        operation="process"
5        bpelx:detailLabel="detailProcessComplete1"
6        bpelx:invokeAsDetail="true">
Two things in here are needed. The first is the bpelx:invokeAsDetail=”true” and the second is the bpelx:detailLabel=”detailProcessComplete1″
The last property is used in cases in which we have multiple detail processes and the signals need to get correlated back with the master process.
Now lets see what is needed in the first detail process to receive the signal and eventually send one back to the master process.
The first activity after the receive is the receive signal
1<bpelx:receiveSignal name="WaitOnSignalFromMaster"
2                     label="doDetail1" from="master"/>
This will receive the signal from its master process and after that will carry on. Without the signal the detail process won’t get started. So you will only be able to trigger this detail/sub process from it’s master process.
After receiving the signal the detail process can execute some logic and eventually send back the signal to the master process
1<bpelx:signal name="ReplyBackToMaster"
2              label="detailProcessComplete1" to="master"/>
In the master process we use the receiveSignal activity to receive it back from the detail process and go on with the process.
1<bpelx:receiveSignal name="waitForDetailProcess1"
2                     label="detailProcessComplete1" from="details"/>
The same code is needed to invoke the second detail process. It’s up to you to decide wether or not the second detail process can run parallel to the first one.
If this is not the case we need to wait on the receiveSignal from the first detail process before we can start the second one.

If both processes can execute their logic and eventually send the signal back we can also receive both signals on the end of the master process. If both signals are receive we can do the callback because the whole process (master and all his details have been completed).
And in this case we can invoke the detail processes like oneway processes, but still inform the master process about the state of all these oneway (long running?) processes. At the end aggregate all the signals and do the callback or some other activity which is needed as soon all the detail processes reported back.

Testcase1
What will happen if we remove one of the receiveSignals from the Master process.

the master process will wait on the receivesignal activity until it receveid it.
Testcase2
What will happen when we do not send the signal from the master process to the detail process but leave the receiveSignal in the detail process.


The master process will wait on the receiveSignal from detail process1. Since the invoke of the both detail processes are oneway and we do the ‘check’ on the receiveSignals at the end, detail process1 will just complete and send the signal back to the master process. After this the master process will keep on waiting on the signal from detail process1.
Testcase3, when all just works




Eventually the flow of the master process can look like this.
In here i placed the receiveSignals to the end of the process. You can also place them after the invokes of the detail processes, so you’re sure they will wait on each other.

Resources
Amis weblog
Tom Hofte weblog
Oracle® Fusion Middleware Developer’s Guide for Oracle SOA Suite 11g Release 1 (11.1.1) – 15 Coordinating Master and Detail Processes
JDeveloper Project

Oracle Fusion Middleware 11g (ofm11g) on Centos 5

The new Oracle Fusion Middleware 11g just got released a few days back, so time to play with it!
Oracle did a great job on the installation guide and quickstart again, so installation wasn’t a real hard job.
A short overview of the steps we need to follow
  • Install Oracle Database (i used OracleXE)
  • Create Schemas for Oracle SOA Suite and Oracle BAM by using Repository Creation Utility (RCU)
  • Install Oracle WebLogic Server and Create the Middleware Home
  • Installing Oracle SOA Suite
  • Configuring Oracle SOA Suite
  • Post-Installation Tasks
  • Installing Oracle SOA Suite Design-Time Components
On the download page i downloaded the next components
Quiet some software to install before we can get started.
I assume you already have the db running so lets get on to the next step.

Create Schemas for Oracle SOA Suite and Oracle BAM by using Repository Creation Utility (RCU)

Unzip ofm_rcu_linux_11.1.1.1.0_disk1_1of1.zip and run ./rcu
I needed to change the next parameters in the db
  • alter system set PROCESSES=500 scope=SPFILE;
  • alter system set open_cursors=500 scope=SPFILE;
And the next parameters in the linux kernel (/etc/security/limits.conf)
1# tbv oracle soa suite 11g
2oracle          hard    nofile  4096
3oracle          soft    nofile  4096
And a list of missing/wrong version of system packages
01Root
02Checking operating system certification
03Expected result: One of enterprise-4,enterprise-5,redhat-4,redhat-5,SuSE-10
04Actual Result: redhat-5
05Check complete. The overall result of this check is: Passed
06 
07Checking recommended operating system packages
08Checking for gcc-4.1.0-28.4; Not found. Failed &lt;&lt;&lt;&lt;
09Checking for gcc-c++-4.1.0-28.4; Not found. Failed &lt;&lt;&lt;&lt;
10Checking for setarch-1.6-1; found setarch-2.0-1.1-i386. Passed
11Checking for sysstat-5.0.5-1; Not found.  Failed &lt;&lt;&lt;&lt;
12Checking for libstdc++-4.1.0-28.4; found libstdc++-4.1.2-44.el5-i386. Passed
13Checking for libstdc++-devel-4.1.0-28.4; Not found. Failed &lt;&lt;&lt;&lt;
14Checking for compat-libstdc++-296-2.96-132.7.2; Not found.  Failed &lt;&lt;&lt;&lt;
15Checking for compat-db-4.1.25-9; Not found. Failed &lt;&lt;&lt;&lt;
16Checking for control-center-2.8.0-12; found control-center-1:2.16.0-16.el5-i386.  Passed
17Checking for glibc-common-2.3.4-2.9; found glibc-common-2.5-34-i386.  Passed
18Checking for binutils-2.16.91.0.5-23.4; found binutils-2.17.50.0.6-9.el5-i386.  Passed
19Checking for make-3.80-202.2; found make-1:3.81-3.el5-i386. Passed
20Check complete. The overall result of this check is: Failed &lt;&lt;&lt;&lt;
21Checking kernel parameters
22Checking for VERSION=2.6.18; found VERSION=2.6.18-128.1.16.el5. Passed
23Checking for hardnofiles=4096; hardnofiles=1024.  Failed &lt;&lt;&lt;&lt;
24Checking for softnofiles=4096; softnofiles=1024.  Failed &lt;&lt;&lt;&lt;
25Check complete. The overall result of this check is: Failed &lt;&lt;&lt;&lt;
26Checking Recommended glibc version
27Expected result: ATLEAST=2.5-12
28Actual Result: 2.5-34
29Check complete. The overall result of this check is: Passed
30 
31Checking physical memory
32Expected result: 1024MB
33Actual Result: 1196MB
34Check complete. The overall result of this check is: Passed
Install all the correct packages (yum available/yum install), and ignore the other warnings during install.
rcu1
rcu2
Setup your own db instance
rcu3
rcu4
I selected just all the components
rcu5
rcu6
rcu7
rcu8
rcu9
rcu10
rcu11

Install Oracle WebLogic Server and Create the Middleware Home

chmod the bin file and run ./oepe11_wls1031_linux32.bin
I had some ‘wrong class version exceptions’, so installed java6 update14.
wls1
Create a new home
wls2
wls3
wls4
wls5
wls6
wls7
wls8
wls9
wls10
wls11

Installing Oracle SOA Suite

Unzip ofm_soa_generic_11.1.1.1.0_disk1_1of1.zip and run ./runInstaller in Disk1
soa1
soa2
soa3

Configuring Oracle SOA Suite

Now we need to configure the soa suite installation with the Oracle Fusion Middleware Configuration Wizard.
Go to
1<ORACLE_HOME>/common/bin
and run ./config.sh
soaconfig1
soaconfig2
soaconfig3
Since i used 1 db for all the components, select al the components and config the same db settings
soaconfig4
soaconfig5
soaconfig6
soaconfig7
soaconfig8
soaconfig9
soaconfig10
soaconfig11
soaconfig12
soaconfig13
soaconfig14
soaconfig15
soaconfig16
soaconfig17
Most of the steps are just next, next and a few more next.

Post-Installation Tasks

Start both the AdminServer and the ManagedServers.
AdminServer
1<SOASUITE_HOME>/user_projects/domains/domain_name/startWebLogic.sh
ManagedServers
1<SOASUITE_HOME>/user_projects/domains/domain_name/bin/startManagedWebLogic.sh soa_server1 (default name)
2<SOASUITE_HOME>/user_projects/domains/domain_name/bin/startManagedWebLogic.sh bam_server1 (default name)
On startup it will prompt you for the username/password we used on during installation

Installing Oracle SOA Suite Design-Time Components

For development we will download Oracle JDeveloper 11g R1 (Build 5407).
To be able to create soa projects in it we need to update it with the Oracle SOA Suite Extension.
Go to Help > Check for Updates. Select ‘Oracle Fusion Middleware Products’ in the ‘Search Update Centers’, next and select ‘Oracle SOA Suite Composite Editor 11.1.1.0′.

New consoles (look-and-feel)

weblogic server 10.3.1 console
wlsconsole
enterprise manager
enterprisemanager
Installation is done!
Just a few urls to check if everything went ok
administration server
http://host:admin_server_port (default installation : http://localhost:7001)
wls console
http://host:admin_server_port/console (default installation : http://localhost:7001/console)
enterprise manager
http://host:admin_server_port/em (default installation : http://localhost:7001/em)

Links

Oracle Fusion Middleware Documentation Library
Oracle Fusion Middleware Products Update Center
Oracle11g on CentOS-5, package requirements
Oracle® Fusion Middleware Quick Installation Guide for Oracle SOA Suite11g Release 1 (11.1.1)
Ready to create some nice new fusion apps!

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">
06    <BusinessFault xmlns="http://nl.iteye/integration/faults/business">
07      <FaultCode>999</FaultCode>
08      <FaultMessage>Something went wrong!</FaultMessage>
09    </BusinessFault>
10  </part>
11</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 :
1<faultName xmlns:flt="http://nl.iteye/integration/faults/business" name="flt:BusinessFault">
2         <condition>
3                 <action ref="ora-human-intervention"/>
4         </condition>
5</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.

1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Oracle JDeveloper 11g Fusion, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Oracle JDeveloper 11g Fusion. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Nitesh Kumar
    MaxMunus
    E-mail: nitesh@maxmunus.com
    Skype id: nitesh_maxmunus
    Ph:(+91) 8553912023
    http://www.maxmunus.com/



    ReplyDelete