【问题标题】:Based on configured schedule the given trigger will never fire Quartz根据配置的时间表,给定的触发器永远不会触发 Quartz
【发布时间】:2020-11-28 10:07:46
【问题描述】:

下面是代码,

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.

不明白为什么会这样? 与 .startNow() 也得到相同的错误。

任何帮助将不胜感激。

【问题讨论】:

  • 这真的很奇怪。你能分享你的应用程序或它的简化版本吗?我可以尝试使用我的本地 QuartzDesk 安装来分析发生了什么,并在此处分享结果。

标签: java quartz-scheduler scheduling


【解决方案1】:

看来你的开始和日期是一样的:

Timezone startDate --- Sat Nov 28 15:30:00 IST 2020 Timezone endDate --- Sat Nov 28 17:30:00 IST 2020

它们仅在几个小时内有所不同,但石英调度程序的工作方式是结束日期必须至少比开始日期晚一天。 您可以尝试通过删除.endAt(endDate) 进行测试,它应该可以工作。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-05-22
    相关资源
    最近更新 更多