0

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);
4

1 回答 1

0

假设您知道已存储的作业的名称(“storedJob”),这对您有用吗?

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

scheduler.scheduleJob(trigger);
于 2009-11-19T14:13:43.670 回答