English 中文(简体)
How to call a CronTriggerBean stored in a JDBCJobStore?
原标题:

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);
问题回答

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




相关问题
Trigger function when Undeploying application

How do I automatically trigger Java function to stop Quartz scheduler jobs when I deploy/undeploy/redeploy JEE5 application in Glassfish.

Quartz API error

When I compile and run my application on my local machine with specs Windows XP sp2, JDK 5u11, I get no error. But when I try to run this application (compiled on Windows XP) on a Linux Debian distro, ...

How to call a CronTriggerBean stored in a JDBCJobStore?

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 ...

How do I start Quartz in standalone mode?

According to its feature list "Quartz can run as a stand-alone program (within its own Java Virtual Machine), to be used via RMI". I could not find any documentation how to start it in stand-alone ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

热门标签