Professional Documents
Culture Documents
When Job Scheduler wishes to invoke a Java based Job, the result will be a call to this
method. In the body of this method, one can then code arbitrary Java calls to achieve
the function that the Job is to perform. In our case, this will result in the invocation of an
SCA module through a Web Service binding.
An illustrative solution
To demonstrate how these tasks can be achieved, we will work through a simple
scenario. We will assume that you have downloaded and installed the latest version of
Job Scheduler. This can be found at the Job Scheduler web site:
http://jobscheduler.sourceforge.net/
The operation that is defined is very simple and configured to be one-way. When a Job
is started, it isnt clear what it would mean to return a response. There is nothing to
prevent request/response calls being made but the process would have to be relatively
short running which may not be the case. It is suspected that Job Scheduler can
examine the response from preceding jobs and based on the results; determine whether
or not to proceed to subsequent jobs.
The BPEL Process itself is also trivial. It looks as follows:
When invoked, it merely logs to the console that it has been called. Obviously this
could be an arbitrarily complex process that performs any amount of business
processing but our primary goal here is to illustrate that a process can be started by the
Job Scheduler. If we see a message in the console, we will know the process ran. If
this type of process can be started, we should be able to happily assume any process
could be started.
Page | 2
In the SCA Assembly diagram, the process is exposed as a Web Service through an
SCA Export component with Web Service bindings.
So far, we have done nothing special relating to Job Scheduler. Everything described
up to this point has been basic WPS oriented activities but what we have achieved is to
set the stage by building and describing a simple test environment. Our goal now is to
invoke the BPEL process called MyProcess at scheduled intervals through the Job
Scheduler environment.
The overall schematic is shown in the following image.
Job Scheduler will be configured with Job definitions that say what needs to happen and
when. When a Job that is to be executed on WPS is ready to be executed, custom
Java code will be called which will make a Web Services call to WPS which will in turn
execute the process when the request is received.
Page | 3
The next step in our solution is to build the Java Job code. We will start by building a
simple Java Project in WID. We called our project SampleJavaJob. Since this code
needs to make a Web Service call to WPS, it is now time to build the Web Service client
caller function. WID has the ability to take a WSDL file and generate all the Java code
needed to invoke the service described by this WSDL. This makes calling a Web
Service from Java a very easy proposition. The generated code will eventually be
invoked by the Job Scheduler.
Expand the Business Integration View module and Web Service Ports. There you will
find a Web Service definition for the export from the SCA Module. Right click on this
entry and select Web Services Generate Client.
Change the Web service runtime to be IBM WebSphere JAX-WS and change the
client project to be SampleJavaJob. This is the Java project we created earlier and is
where the generated Java classes that call the Web Service are to be stored.
Page | 4
All the other settings can remain with their default settings. At the conclusion of this
wizard activity, Java code will have been generated that will invoke the process as a
Web Service. It is this code that we wish to invoke from within the Job Scheduler. Our
next steps will be the creation of the Job Scheduler wrapper class.
Modify the build path of the Java profile within WID to include the sos.spooler.jar
that is supplied with Job Scheduler and found in the <Scheduler>/lib folder. This
Jar contains classes that we will need in our custom code. It provides the contract
between Job Scheduler and the custom Job we are writing.
Figure 6 Adding the Job Scheduler Jar file to the build path
Create a new Java class that extends sos.spooler.Job_impl. We named this class
SampleJavaJob. By extending the Job Scheduler supplied class, we inherit the
necessary contracts and framework for Job Scheduler to invoke our own custom code.
Page | 5
Page | 7
One final change must be made to the Job Scheduler configuration. This change is a
little more subtle. In order to invoke the IBM Web Services calls, the Java runtime of
Job Scheduler must use the IBM Java Runtime (JVM). It is not sufficient to simply run
Job Scheduler with this JVM in the program path. Job Scheduler provides a second
configuration file called sos.ini which is again found in the <scheduler>/config
folder. This file should be edited and an entry under [java] should be added. An
entry called vm should be added which points to the jvm.dll file provided by the IBM
Java runtime. In our example we used the WPS runtime JVM file found in
<WPS>/java/jre/bin/j9vm.
The resulting entry in sos.ini looks as follows:
[java]
;vm = C:\Program Files\Java\jre6\bin\client\jvm.dll
vm = C:\Program Files\IBM\WID62\runtimes\bi_v62\java\jre\bin\j9vm\jvm.dll
With these changes made, we are now ready to start Job Scheduler.
From a DOS window and located in the <scheduler>/bin directory, we run the
command:
jobscheduler.cmd start
The program runs and holds the DOS Window open. In production, it would be started
from the Windows Services.
We are now ready to define the Job to the scheduler. Launch the Job Scheduler editor
by running the command jobeditor.cmd.
Create a new job from the menu
File New Hot Folder Element Job
Page | 9
Give the new Job a meaningful name, for example BPEL Process.
Next click on the Execute element in the left pane to define how the Job will run.
Define the job to be a script and written in Java. In the Classname field, enter the full
name of the Java Job class including its package name. Remember that in a previous
set of steps we exported the implementation of this class as a Jar file and then added
the Jar into the class path of Job Scheduler.
Page | 10
Page | 11
Make sure that the SCA Module we are about to call is installed and running in the WPS
server. In the next step we are about to execute it. Clicking on the Job definition shows
us details of that Job. In the Job menu, we find and select an entry called Start
task unforced now. This will cause Job Scheduler to run an instance of the job
immediately. This will prove to us that Job Scheduler is able to invoke the process.
After completion and clicking on the Update button, the result will be:
Page | 12
If we examine the history in the console log of WPS, we will have found that the process
will have executed. What remains is to schedule the work to be executed at configured
times in the future, for our testing purposes; we will have the process run every 15
seconds.
From the Job menu, select Set run time.
Page | 13
Click on the run time editor button to launch the assistance window for creating
run time specifications.
In the assistance window, enter a value of 15 seconds in the Repeat Time field.
Complete the changes and then watch the results. After a short period of time we will
find that the process has executed every 15 seconds.
Page | 14
Obviously Job Scheduler has a lot of features and we have barely scratched the surface
on how to use it but what this paper has shown is how to expose a Business Process as
a Web Service, how to write a Java Job wrapper to call that Web Service, how to define
the Java Job to Job Scheduler and finally how to run a simple test to ensure that Job
Scheduler can correctly call the process.
Page | 15