views:

132

answers:

1

Hi,

I need some help. I am using Quartz Scheduling and have configured a CronTrigger to run each night at 10PM. I am using the JDBCJobStore to take advantage of the Clustering.

The job runs at 10PM every night but I want to be able to call the job programmatically to run it on the fly if needed but I still want to take advantage of the clustering(Ie. I don't want multiple people being able to run the job).

Is there a way to get the CronJob from the store and run it while still taking advantage of the clustering option? For example now, the 1st server that wakes up the job runs, when the other server in the cluster wakes up it doesn't run if the job is already started.

I am able to do this like this but it start as a separate job.... which is not what I want.

scheduler = StdSchedulerFactory.getDefaultScheduler();
 scheduler.start();
/ Create the JobDetail
JobDetail jobDetail = new JobDetail("cronTrigger", Scheduler.DEFAULT_GROUP, MyCronJob.class);

// Create a trigger that fires once right away
Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 0);
trigger.setName("FireOnceNowTrigger");
scheduler.scheduleJob(jobDetail, trigger);
A: 

Assuming you know the name of the job you have already stored ("storedJob"), does this work for you?

Trigger trigger = TriggerUtils.makeImmediateTrigger(0, 0);
trigger.setName("FireOnceNowTrigger");
trigger.setJobName("storedJob");
trigger.setJobGroup(Scheduler.DEFAULT_GROUP);

scheduler.scheduleJob(trigger);
Dennis S.