Scheduler plugin : start Scheduler

Hi,

I run a cron job using the Scheduler plugin to keep a constant open connection (basically just sends an SQL query every 30 minutes). Generally speaking it works OK (klugey work around to keep a connection to an Oracle datasource that IS NOT shut down by the Oracle server - seems to be shut down by the network here somehow). Every once and a while though something does shut down the connection regardless. At that point I try to go and reset the cron job and I get the message :

java.lang.RuntimeException: Couldn't schedule job cronJob1 error: The Scheduler has been shutdown. (cronJob1, line 11)

There doesn’t seem to be anything in the Method editor for restarting the Scheduler. Noseying around on the web I came across this:
http://quartz.sourceforge.net/firstTutorial.html#using
which gives this as possible code:

schedFact = new org.quartz.impl.StdSchedulerFactory();
sched = schedFact.getScheduler();
sched.start();

This doesn’t work directly within a method however. Can anyone point me how to ‘Start’ the Scheduler?

Hi John

Not sure if it solves your problem but this is code I use for a client who needs connection kept open when on poor quality WiFi connections:

var vCronJobs = plugins.scheduler.getCurrentJobNames()
	plugins.scheduler.addCronJob('ServerTime00', '00 0/1 * * * ?', globals.jc_getServerTime)
	plugins.scheduler.addCronJob('ServerTime20', '20 0/1 * * * ?', globals.jc_getServerTime)
	plugins.scheduler.addCronJob('ServerTime40', '40 0/1 * * * ?', globals.jc_getServerTime)

The Global method just shows the current Server time in Status area every 20 secs to reassure them that the connection still open.

var vServerTime = application.getServerTimeStamp()
application.setStatusText(vServerTime)

HTH

Graham Greensall
Worxinfo Ltd

Hi Graham,

Thanks for the reply. Actually my problem is that at times the Scheduler itself shuts down. The ‘cronjobs’ run ok (in my case just simple queries to the respective databases). But for some reason the Scheduler will sometimes stop and then the only way to get it going is to restart the server (or developer if I’m working on that). So I’m trying to see how one ‘restarts’ the scheduler without having to do that.

John

Hi John,

I have had experiences with the scheduler (running in a batch process) stopping after a method caused an error. Odd thing was that it didn’t log anything (other than in a trace log).
Only option to fix it was to restart the batch process.

Maybe this is some safety feature so that buggy scheduled jobs won’t stay running.

Anyway, I would suggest you check out if the method got an error and see if you can catch or fix it.

Hope this helps.

Hi Graham,

grahamg:

var vCronJobs = plugins.scheduler.getCurrentJobNames()
plugins.scheduler.addCronJob('ServerTime00', '00 0/1 * * * ?', globals.jc_getServerTime)
plugins.scheduler.addCronJob('ServerTime20', '20 0/1 * * * ?', globals.jc_getServerTime)
plugins.scheduler.addCronJob('ServerTime40', '40 0/1 * * * ?', globals.jc_getServerTime)

You can optimize that code by using the following.

plugins.scheduler.addCronJob('ServerTime', '0/20 0/1 * * * ?', globals.jc_getServerTime)

Hope this helps.

Hi Robert

Thanks for this. Always happy to learn from a maestro :)

All the best

Graham Greensall
Worxinfo Ltd