gpt4 book ai didi

java - Quartz 触发同一个实例两次

转载 作者:搜寻专家 更新时间:2023-11-01 03:50:02 24 4
gpt4 key购买 nike

我们在 Java 类中使用 DisallowConcurrentExecutionAttribute 注释来防止多个实例的并发执行,但是,看起来 Quartz 已经同时触发了同一个实例两次。请解决此问题并向我们提供更多信息,如果这是一个错误,请修复此问题。

@Override
@Transactional(propagation = Propagation.REQUIRED, readOnly = false)
public void execute(final JobExecutionContext jobExecutionContext) throws JobExecutionException {
logger.log(Log.DEBUG, "++++ Quartz JOB BatchJobDetector started");
try {
this.setJobExecutionContext(jobExecutionContext);
boolean triggerNextJob = true;
while (triggerNextJob) {
TriggeredBatchProcessDTO triggeredBatchProcessDTO = getNextJob(jobExecutionContext, 0);
if (triggeredBatchProcessDTO != null) {

triggerJobImmediatly(triggeredBatchProcessDTO.getId(), jobExecutionContext);
triggeredBatchProcessDTO.setState(StatusType.RUNNING);
triggeredBatchProcessDTO.setProcessDtTm(triggeredBatchProcessDTO.getProcessDtTm());//CRGRO022
updateTriggeredBatchProcessDTO(triggeredBatchProcessDTO);

} else {
triggerNextJob = false;
}
}
} catch (final UnexpectedRuntimeException e) {
logger.log(Log.ERROR, "Error during execution of TriggeredBatchProcessDetectorJob: " + e.getMessage(), e);
throw e;
} catch (final Throwable t) {
throw new UnexpectedRuntimeException(CoreExceptionId.RUN_0001_UNEXPECTED_EXCEPTION,
new Object[] { "TriggeredBatchProcessDetectorJob error" }, t);
}
logger.log(Log.DEBUG, "++++ Quartz JOB BatchDetector finished");
}

最佳答案

您需要通过属性正确设置 quartz 才能将其运行到集群模式,我不确定,但恕我直言,您还应该使用 @PersistJobDataAfterExecution 注释。我使用的是集群 quartz ,没有任何问题,也没有任何问题,也有贬低的工作实现 StatefulJob .您需要向我们展示您的配置 - here is sample - 并提供 quartz 库版本

关于java - Quartz 触发同一个实例两次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31051161/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com