Quartz Scheduler:在3的线程池下重新运行同一作业

时间:2019-02-08 09:41:38

标签: spring quartz-scheduler

我正在尝试将Quartz Scheduler集成到我们的Spring应用程序中,具有10个作业,每个作业执行3分钟(Thread.sleep(3Min)),每个作业在每小时的第59分钟运行,如下cron表达式所示。

  

0 0/59 * * *?

注意:不使用任何群集,而是将JDBC存储作为MySQL使用,仅在一台计算机上运行。

要解释以下输出

  • 职位名称用 BSQJ-
  • 表示
  • “ ENTERED”是指进入作业执行状态。
  • “正在退出”表示退出Job执行状态。

输出如下:

INFO: Server startup in 55196 ms
ENTERED: Job Execution for the JOb Name:  BSQJ-1 at the time of 2019/02/08 08:59:00
ENTERED: Job Execution for the JOb Name:  BSQJ-2 at the time of 2019/02/08 08:59:01
ENTERED: Job Execution for the JOb Name:  BSQJ-3 at the time of 2019/02/08 08:59:03
Feb 08, 2019 9:00:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 7 trigger(s) that missed their scheduled fire-time.
Feb 08, 2019 9:01:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 3 trigger(s) that missed their scheduled fire-time.
EXITING: the Job Execution for the Job Name:  BSQJ-1 at the time of 2019/02/08 09:02:00
EXITING: the Job Execution for the Job Name:  BSQJ-2 at the time of 2019/02/08 09:02:01
ENTERED: Job Execution for the JOb Name:  BSQJ-1 at the time of 2019/02/08 09:02:02
Feb 08, 2019 9:02:03 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 7 trigger(s) that missed their scheduled fire-time.
EXITING: the Job Execution for the Job Name:  BSQJ-3 at the time of 2019/02/08 09:02:03
ENTERED: Job Execution for the JOb Name:  BSQJ-2 at the time of 2019/02/08 09:02:09
ENTERED: Job Execution for the JOb Name:  BSQJ-4 at the time of 2019/02/08 09:02:11
Feb 08, 2019 9:03:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 1 trigger(s) that missed their scheduled fire-time.
Feb 08, 2019 9:04:03 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 6 trigger(s) that missed their scheduled fire-time.
EXITING: the Job Execution for the Job Name:  BSQJ-1 at the time of 2019/02/08 09:05:02
Feb 08, 2019 9:05:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 1 trigger(s) that missed their scheduled fire-time.
ENTERED: Job Execution for the JOb Name:  BSQJ-5 at the time of 2019/02/08 09:05:04
EXITING: the Job Execution for the Job Name:  BSQJ-2 at the time of 2019/02/08 09:05:09
EXITING: the Job Execution for the Job Name:  BSQJ-4 at the time of 2019/02/08 09:05:11
ENTERED: Job Execution for the JOb Name:  BSQJ-3 at the time of 2019/02/08 09:05:11
Feb 08, 2019 9:06:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 5 trigger(s) that missed their scheduled fire-time.
ENTERED: Job Execution for the JOb Name:  BSQJ-6 at the time of 2019/02/08 09:06:08
Feb 08, 2019 9:08:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 4 trigger(s) that missed their scheduled fire-time.
EXITING: the Job Execution for the Job Name:  BSQJ-5 at the time of 2019/02/08 09:08:04
ENTERED: Job Execution for the JOb Name:  BSQJ-7 at the time of 2019/02/08 09:08:07
EXITING: the Job Execution for the Job Name:  BSQJ-3 at the time of 2019/02/08 09:08:11
ENTERED: Job Execution for the JOb Name:  BSQJ-8 at the time of 2019/02/08 09:08:13
EXITING: the Job Execution for the Job Name:  BSQJ-6 at the time of 2019/02/08 09:09:08
Feb 08, 2019 9:10:03 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 2 trigger(s) that missed their scheduled fire-time.
ENTERED: Job Execution for the JOb Name:  BSQJ-9 at the time of 2019/02/08 09:10:07
EXITING: the Job Execution for the Job Name:  BSQJ-7 at the time of 2019/02/08 09:11:07
EXITING: the Job Execution for the Job Name:  BSQJ-8 at the time of 2019/02/08 09:11:13
Feb 08, 2019 9:12:02 AM org.quartz.impl.jdbcjobstore.JobStoreSupport recoverMisfiredJobs
INFO: Handling 1 trigger(s) that missed their scheduled fire-time.
ENTERED: Job Execution for the JOb Name:  BSQJ-10 at the time of 2019/02/08 09:12:05
EXITING: the Job Execution for the Job Name:  BSQJ-9 at the time of 2019/02/08 09:13:07
EXITING: the Job Execution for the Job Name:  BSQJ-10 at the time of 2019/02/08 09:15:05

从上到下的问题如下:

  1. 在第一次出现时,启动三个作业后,调度程序具有 作为处理7个未按计划点火时间的触发器而给出的, 然后立即给出另一个声明,因为处理3会触发 错过了他们预定的开火时间,然后更改为3 触发器。为什么会这样,最初我的理解是,可能是 更新错过的触发器的触发时间,但是当 即使没有其他新职位,也从7个触发器更改为3个 为何将其更改为3个触发器然后是6个触发器?
  2. 很高兴在将线程池设置为3时开始执行3个作业,但是一旦执行完毕,为什么 BSQJ-1和BSQJ-2(第一个和第二个工作)为两个相同的工作 不管他们必须在 下个小时的下一个59分钟。 ?我不明白为什么会这样 发生了,我是否缺少任何要设置的配置。
  3. 如上所述,在第二点中,当我计算出执行总数为10个作业中的13个时,这意味着3个作业被重新执行。 这让我感到困惑,并想知道我是否犯了任何错误。

    如果Quartz Scheduler的行为方式如此,那么我需要更改设计以维持工作的独立状态,无论是否完成。如果未完成,则在该时间实例中针对同一作业再次进行计算。

在此先感谢并感谢您的见解。

0 个答案:

没有答案