Introduction
===============
Quartz is an open source job scheduler, that can integrated with any J2EE and J2SE applications.
In BPEL Process Manager, quartz is implemented as part of java class called DefaultSchedulerCalloutImpl.
AIM
=====
In this note we will try to generate a bpel process that will poll for a particular file using file adapter in some specific period of time.
Design
=========
Create a new bpel Process
Once the process is created Drag and drop an file adapter in the swimlane of the bpel process.
In the file pattern give *.* which means it can accept any type of file.
Change the polling frequency to 1 seconds
To make it simple i will use native schema for processing.
Say next and finish.
Once finished you will get the following screen in the swim lane of your process.
Now drag and drop a receive activity in the process and connect it to the file adapter.Once you will connect the file adapter to the receive activity you will get a screen where in you can define the variable and don't forget to select the create instance button over there.
NOw just to make sense of this project create a new variable and assign it the value that you are getting from the file adapter.something like this my assign will look
So once completed your process should look like this
Now if you will look at the application navigator you can find that there are two files which are created for the file adapter.
One is PickFile.wsdl
This file contains all the information that you have provided while creating a file adapter through gui that is the file location the frequency etc.
Additionally the tool itself generates a file called as fileAdapterInboundHeader.wsdl
It contains the header information.
We are often asked a question that can you create a scenario where in the output file name has same name as input file name.It is very easy you just get the input file name create a variable and assign it that name.Again in the outbound provide this name as the header.I will probably come up with full explanation sometimes later.
This was just to give a fair idea about what is going behind the scene.
Now the main setting.Just open the bpel.xml file for this service
you might get following entry if you have followed my screenshots
<?xml version = '1.0' encoding = 'UTF-8'?>
<BPELSuitcase>
<BPELProcess id="ScheduleProcess" src="ScheduleProcess.bpel">
<partnerLinkBindings>
<partnerLinkBinding name="PickFile">
<property name="wsdlLocation">PickFile.wsdl</property>
</partnerLinkBinding>
</partnerLinkBindings>
<activationAgents>
<activationAgent className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent" partnerLink="PickFile">
<property name="portType">Read_ptt</property>
</activationAgent>
</activationAgents>
</BPELProcess>
</BPELSuitcase>
We have a partner link binding which connects to the file adapter wsdl file.
We have one more thing called as activation agent.
Activation agent is nothing but a initializing parameter.You have an activation agent to whom you order that you have to pick the file so it is the starting point of the process in our case.It activates the file adapter to pick the file from the required location.
so we need to make some changes in the bpel.xml
I will change the code in bpel.xml to the following
<?xml version = '1.0' encoding = 'UTF-8'?>
<BPELSuitcase>
<BPELProcess id="ScheduleProcess" src="ScheduleProcess.bpel">
<partnerLinkBindings>
<partnerLinkBinding name="PickFile">
<property name="wsdlLocation">PickFile.wsdl</property>
</partnerLinkBinding>
</partnerLinkBindings>
<activationAgents>
<activationAgent className="oracle.tip.adapter.fw.agent.jca.JCAActivationAgent"
partnerLink="PickFile" heartBeatInterval="10">
<property name="portType">Read_ptt</property>
<property name="schedulerCallout">DefaultSchedulerCalloutImpl</property>
<property name="endpointScheduleOn">0 0 21 * * ?</property>
<property name="endpointScheduleOff">0 30 21 * * ?</property>
</activationAgent>
</activationAgents>
</BPELProcess>
</BPELSuitcase>
Now we will check what all changes we have done.
The first thing as you can notice is that i have added a property called as
heartBeatInterval="10"
The heartBeatInterval is measured in seconds, it specify that how frequently the schedule is checked. The quartz scheduler turns heartbeat on and off.
Again we have added
<property name="schedulerCallout">DefaultSchedulerCalloutImpl</property>
<property name="endpointScheduleOn">0 0 21 * * ?</property>
<property name="endpointScheduleOff">0 30 21 * * ?</property>
as we have discussed we have Quartz implemented as part of java class named DefaultSchedulerCalloutImpl so we are just calling it here.
The next two properties decide when to start the polling and when to stop it
The attribute for endpointScheduleOn and endpointScheduleoff element is cron sequence.
For more knowledge in quartz i will suggest you to go through the following documentation.
http://www.quartz-scheduler.org/docs/tutorial/
I have not done more analysis in cron job sequence but in my case
I am telling my scheduler to start at 09 and end at 09:30
<property name="endpointScheduleOn">0 0 21 * * ?</property>
<property name="endpointScheduleOff">0 30 21 * * ?</property>
So 21 here is hours and 30 is seconds.This is just an example you can look the docs and design for your own requirement.
My process will start scheduling at 9 pm and will end at 9:30 pm (21:30).
Now once the process is completed deploy and check if it works for you or not.It worked for me.
This is one of the approach you can schedule your process another approach is that you can schedule your process from database ,i don't have much knowledge in database but i will try to create one.
There is one excellent document for doing this
http://hugues.simonnet.free.fr/logiciels/blog/070114_BPEL_Scheduler.pdf
so you can go ahead with this also.
you can download the project from following location
2 comments:
HI, Y DID TRY DOWNLOAD FILE TO TEST, BUT DONT AVAILABLE LINK.
PLEASE HELP ME.
THANK YOU
This is an old post and the location where i have uploaded all my projects seems to be scrapped so i have no way to find the project. I believe the steps are very much self explanatory, Try to implement the steps and let me know if you get stuck in some step. More over i will suggest we have Enterprise scheduler service (ESS) as a part of SOA 12c. It is very easy to use and configure and can be learned much easily. You may try to use this feature.
Post a Comment