根据配置的时间表,给定的触发器永远不会触发

falq053o  于 2021-07-08  发布在  Java
关注(0)|答案(1)|浏览(518)

下面是代码,

Trigger trigger = TriggerBuilder
            .newTrigger().withIdentity(job.getTriggerName(), job.getGroupName())                    
            .withSchedule(CronScheduleBuilder.cronSchedule(new CronExpression(cronExpression)).inTimeZone(TimeZone.getTimeZone(remoteTimezone)).withMisfireHandlingInstructionFireAndProceed())                 
            .startAt(startDate)
            .endAt(endDate)                 
            .build();

下面是日志,

[11-28 15:30:00,906] [pool-1-thread-1] [INFO:QuartzJob:99] job.getStartTimes() - 10:00,11:00,12:00
[11-28 15:30:00,908] [pool-1-thread-1] [INFO:QuartzJob:105] dateValue - Sat Nov 28 15:30:00 IST 2020
[11-28 15:30:00,909] [pool-1-thread-1] [INFO:QuartzJob:105] dateValue - Sat Nov 28 16:30:00 IST 2020
[11-28 15:30:00,910] [pool-1-thread-1] [INFO:QuartzJob:105] dateValue - Sat Nov 28 17:30:00 IST 2020
[11-28 15:30:00,913] [pool-1-thread-1] [INFO:QuartzJob:130] mins --- 30
[11-28 15:30:00,913] [pool-1-thread-1] [INFO:QuartzJob:131] hours --- 15,16,17
[11-28 15:30:00,913] [pool-1-thread-1] [INFO:QuartzJob:132] Timezone startDate --- Sat Nov 28 15:30:00 IST 2020
[11-28 15:30:00,913] [pool-1-thread-1] [INFO:QuartzJob:133] Timezone endDate --- Sat Nov 28 17:30:00 IST 2020
[11-28 15:30:00,913] [pool-1-thread-1] [INFO:QuartzJob:137] Generated cronExpression for the Job is - 0 30 15,16,17 * * ?

作业开始时间值以gmt为单位,转换为ist并生成cron表达式。但是得到下面的错误,

[11-28 15:30:00,936] [pool-1-thread-1] [ERROR:JobExecutor:71] org.quartz.SchedulerException: Based on configured schedule, the given trigger '2020-11-28-DUMMY_JOB_TEST-Jobs.2020-11-28-DUMMY_JOB_TEST-Trigger' will never fire.

不明白为什么会这样?with.startnow()也会得到相同的错误。
任何帮助都将不胜感激。

smdncfj3

smdncfj31#

看来你的出发日期是一样的: Timezone startDate --- Sat Nov 28 15:30:00 IST 2020 Timezone endDate --- Sat Nov 28 17:30:00 IST 2020 它们只在几个小时内有所不同,但quartz调度器的工作方式是,结束日期必须至少比开始日期晚一天。您可以尝试通过删除 .endAt(endDate) ,应该有用。

相关问题