如何调用存储在 JDBCJobStore 中的 CronTriggerBean?
我需要一些帮助。我正在使用 Quartz Scheduling 并配置了 CronTrigger 以在每晚 10 点运行。我正在使用 JDBCJobStore 来利用集群。
该作业每天晚上 10 点运行,但我希望能够以编程方式调用该作业,以便在需要时即时运行它,但我仍然想利用集群的优势(即,我不希望多个人能够运行工作)。
有没有办法从商店获取 CronJob 并运行它,同时仍然利用集群选项?例如,现在,唤醒作业的第一台服务器运行,当集群中的其他服务器唤醒时,如果作业已经启动,则它不会运行。
我可以这样做,但它作为一项单独的工作开始......这不是我想要的。
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);
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);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
假设您知道已存储的作业的名称(“storedJob”),这对您有用吗?
Assuming you know the name of the job you have already stored ("storedJob"), does this work for you?