[Opensource] Expresso Job Control: A little inadequate
Eddie Lewis
ELewis at copyright.com.au
Tue Oct 22 16:18:22 PDT 2002
Peter - i submitted a document a few months ago which may help a little
i have included the body of it below for you to use if it is helpful.
Regards Eddie Lewis
----------------------------------------------------------------------------
--------------------------------
We have spent some time going through the jobs service in expresso and would
like to add some more information to what we found in relation to the
process.
Firstly, Peter Carapetyan jobs tutorial is the first point of call (I have
included the zip file of the tutorial). This explains a lot for the job
service, I am just adding to its content.
We performed the steps as outlined in the tutorial
Created a "job" object (copy and modify
com.jcorporate.expresso.core.TestJob).
Create the job queue entry.
The JobHandler object then constantly reviews the queue and searches for
records with where clause of - Status Code='Available' AND Handling Server=0
AND Required Job OS Name in ('Windows 2000','MSWIN','any')
Once the job starts, the status is set to running
JobHandler checks if any entries are in the Cron Parameters field (more on
this below)
Then gets an instance of your job object and runs the thread.
NOTE - this will be a singlethreaded process (will wait for other jobs to
finish before running next in queue)
To make the process multithreaded, your job object must override the
multithreaded method
public boolean multiThreaded() {
return true;
}
It then sets the job Status Code to completed, the Handling Server to -1,
send notifications, etc.
This will not be run again until you change the parameters of the job back
to available and 0. the queue is checked (by default which can be changed)
every 30 seconds and the job would run again straight away.
CRON JOB ENTRIES
We wanted to run the process continually and couldn't find any explanation
of how these entries worked
Looking into JobHandler, it get the queue - determines if its a single or
multithreaded process, checks if its a cron job (has entries in the Cron
Parameters field) and runs it as such or simply runs it as a single job.
In both cases it sets the job to completed and the server to -1 so that the
job is not picked up again.
The difference being that a cron job is added to a cronMgr and is run
continually depending on the parameters entered. The only thing to watch out
for here is if you restart the server, your job has its settings changed and
will not be picked up again. You need to set the Status Code='Available' AND
Handling Server=0 for the server to pick up the entries again.
Be careful - a cron entry is picked up by the server (at the timer interval
set - default 30 seconds).
The status is set to running, however the job is not run until the cron
times are met.
When the first job is run, the status is set to completed. This is true,
however, the job will now continually run when the cron times are met again
as the JobHandler checks the cronMgr as well as anything in the job queue SO
DO NOT change the status, server, etc to try and get the job to run again,
YOU only have to reset these if you restart the server.
We are looking to modify the JobHandler code so it checks a job parameters
entry (I.e something like auto-load) to restart the job each time regardless
of the two parameters above. Yet to be completed.
Cron Parameters - what do they mean
Simply minute,hour,day-of-month,month,day-of-week,year
The JobHandler evaluates these as numbers (cannot use Calendar.FRIDAY) as
they are passed into the Integer.valueOf()
It also uses the StringTokenizer so do not leave any spaces in the string.
use -1 for each entry to imply continual checking for that parameter
The following runs the job every minute, every hour, etc.
-1,-1,-1,-1,-1,-1
The following runs the job on the 26th June at 16:45 (4:45pm) or on any
Tuesday in June at that time for every year
45,16,26,5,3,-1
Things to note - The month and day-of-week entries follow the Calendar
constants
i.e.. June is 5, Tuesday is 3
1st of every month at 9:30
30,9,1,-1,-1,-1
Simple example
So follow the job tutorial to get a handle on how it all holds together
For us this involved
change expresso-config.xml
set <startJobHandler>y</startJobHandler>
create your job class - something like (copy and modify TestJob - the
following is a simple example)
package ......
imports here ......
public class MyTestJob extends Job {
private String thisClass = new String(this.getClass().getName() + ".");
private static Category log = null;
/**
*
*/
public MyTestJob () {
System.out.println("<JOBSTARTED> INSTANTIATED MyTestJob ");
setSchema("schema goes here");
}
public String getTitle() {
return getString("Archive_Job"); // this entry needs to exist in your
message bundle file
} /* getTitle() */
public void run() {
super.run();
String sField = null;
try {
System.out.println("Run method of TestThread executing");
}
finish(getString("An output string from the message bundle file - goes to
an email"));
} catch(Exception de) {
finish(getString("An email error message"), de);
}
}
} /* TestJob */
Goto the expresso Operations page then Job Queue Entries
Add the class (package path included)
requested by user - (they will get an email on completion)
status - available
handling server - 0
OS - any
Cron Parameters - if you want the job to continually run
Restart the server - reset the status and server entries so that the server
picks up the job again
----------------------------------------------------------------------------
---------------
-----Original Message-----
From: Peter A. J. Pilgrim [mailto:peterp at xenonsoft.demon.co.uk]
Sent: Wednesday, 23 October 2002 4:30 AM
To: opensource at jcorporate.com
Subject: [Opensource] Expresso Job Control: A little inadequate
Expresso Job Control
"For technical information about how to use Job Control, please refer to the
Expresso Developers Guide (EDG) or the Javadocs."
I found this documentation a little inadequate. Admittedly this is first
time I looked at Expresso Job control in detail. I remember the EDG circa
Expresso 2.2/3.0 covered this in detail, I think. So I wonder what
happened to the original documentation.
In Michael Nash documentation as it is know he shows a creation of a
JobQueue
but does not show the relationships.
Where is the Job example (com/jcorporate/expresso/utils/TestJob)?
(For example I assume the `com/jcorporate/expresso/utils/TestJob' has to
implement a Java interface but which one? It is not clear at all.
Some code would help)
Can I add this code template and stick it inside a DBObject or Controller?
What happens when you create a JobQueue?
Where is my Job then after submission?
(I assume you can see it in the Admin / Operations screens afterwards)
How can I start the job manually ?
How can I stop the job manually?
How can I pass parameters to the Job and how can the Job pass parameters
back?
I wonder if anyone has some docs they can pitch in or a few sentences
so I can or something can fix the infos. This is important because I
working on enhancing the usability of eForum for everybody and Job
queues are the final piece of the jigsaw.
Ta
--
Peter Pilgrim
ServerSide Java Specialist
My on-line resume and for interview videos about myself, J2EE
Open Source, Struts and Expresso.
||
\\===> `` http://www.xenonsoft.demon.co.uk/no-it-striker.html ''
_______________________________________________
Opensource mailing list
Opensource at jcorporate.com
http://mail.jcorporate.com/mailman/listinfo/opensource
Archives: http://mail.jcorporate.com/pipermail/opensource/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20021023/68e2a939/attachment-0002.htm
More information about the Opensource
mailing list