【问题标题】:how to prevent quartz from running another job if the previous one is still running?如果前一个工作仍在运行,如何防止石英运行另一项工作?
【发布时间】:2023-01-27 19:49:16
【问题描述】:

我正在使用夸库斯。我的 Quartz 作业计划每 10 秒运行一次:

        return TriggerBuilder.newTrigger()
                .withIdentity("my-job")
                .startNow() 
                .withSchedule(
                        SimpleScheduleBuilder.simpleSchedule()
                                .withIntervalInSeconds(10)
                                .repeatForever()
                ).build();

这工作正常,但无论最后一个作业是否完成,作业都会每 10 秒触发一次。仅当当前没有作业正在运行时,我才需要开始下一个作业。我该如何做到这一点?

【问题讨论】:

标签: quarkus quartz


【解决方案1】:

在 Job 类上添加 @DisallowConcurrentExecution。

例如:

@DisallowConcurrentExecution
public class MyScheduledJob implements Job {
 //execution method
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-07
    • 2017-03-14
    • 1970-01-01
    • 1970-01-01
    • 2017-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多