我已将quartz scheduler配置推送到在本地Tomcat服务器上运行的OpenShift应用程序。我已经验证了它从main / resources文件夹中的quartz.properties文件中读取的内容。这是日志和代码。我推动代码几分钟后,我改变了工作的时间表。
public void contextInitialized(ServletContextEvent sce) {
try {
// Setup the Job class and the Job group
JobDetail job = newJob(DailyUpdates.class).withIdentity("CronQuartzJob", "Group").build();
// Create a Trigger that fires every 10 minutes.
Trigger trigger = newTrigger()
.withIdentity("TriggerName", "Group")
.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(8, 55))
.withSchedule(CronScheduleBuilder.dailyAtHourAndMinute(18, 0))
.build();
// Setup the Job and Trigger with Scheduler & schedule jobs
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
scheduler.scheduleJob(job, trigger);
} catch (SchedulerException ex) {
logger.error(ex);
}
}
日志文件说:
2016-05-10 08:52:54 INFO QuartzScheduler:240 - Quartz Scheduler v.2.2.3 created.
2016-05-10 08:52:54 INFO QuartzScheduler:2311 - JobFactory set to: org.quartz.simpl.SimpleJobFactory@8c6fdb
2016-05-10 08:52:54 INFO RAMJobStore:155 - RAMJobStore initialized.
2016-05-10 08:52:54 INFO QuartzScheduler:305 - Scheduler meta-data: Quartz Scheduler (v2.2.3) 'CustomQuartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 5 threads.
Using job-store 'org.quartz.simpl.RAMJobStore' - which does not support persistence. and is not clustered.
2016-05-10 08:52:54 INFO StdSchedulerFactory:1327 - Quartz scheduler 'CustomQuartzScheduler' initialized from default resource file in Quartz package: 'quartz.properties'
2016-05-10 08:52:54 INFO StdSchedulerFactory:1331 - Quartz scheduler version: 2.2.3
2016-05-10 08:52:54 INFO QuartzScheduler:575 - Scheduler CustomQuartzScheduler_$_NON_CLUSTERED started.
2016-05-10 08:52:54 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:52:54 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:53:18 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:53:46 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:54:41 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:55:05 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
2016-05-10 08:55:31 DEBUG QuartzSchedulerThread:276 - batch acquisition of 0 triggers
属性文件:
org.quartz.scheduler.skipUpdateCheck = true
org.quartz.scheduler.instanceName = CustomQuartzScheduler
org.quartz.scheduler.jobFactory.class = org.quartz.simpl.SimpleJobFactory
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 5
答案 0 :(得分:0)
触发器未读取多个计划。我不得不创建多个触发器,每个触发器都有自己的时间表,然后开始工作。