石英调度程序错误地分类了作业以恢复
当我在计算机中运行两个应用程序的实例时。其中一个实例可以接收执行的作业,而其他实例则选择相同的作业以恢复。
根据文档,下面的财产应照顾在多个实例上分发工作。但是,其中一个实例正在选择相同的工作以恢复。
org.quartz.jobStore.isClustered = true
使用Quartz-2.3.2
Quartz.properties
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.instanceName = JobScheduler
org.quartz.threadPool.threadCount = 1
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource = ss
org.quartz.jobStore.isClustered = true
org.quartz.dataSource.ss.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.ss.URL = jdbc:mysql://localhost:3306/ss
org.quartz.dataSource.ss.user = root
org.quartz.dataSource.ss.password = password
代码代码段至
JobDetail jobDetail = JobBuilder
.newJob(JobService.class)
.requestRecovery(true)
.withIdentity(promotionJob.getId().toString(), RulesPromotionConstants.JOB_SCHEDULER_GROUP)
.build();
// see if jobdatamap needs to be added above
Trigger trigger = TriggerBuilder
.newTrigger()
.forJob(jobDetail)
.startAt(Date.from(Instant.ofEpochMilli(promotionJob.getScheduledAt())))
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow())
.withIdentity(promotionJob.getId().toString(), RulesPromotionConstants.JOB_TRIGGER_SCHEDULER_GROUP)
.build();
rulesPromotionScheduler.scheduleJob(jobDetail, trigger);
代码段下方的sschedulejob,如果在实例已经执行相同作业时执行条件,则使用。
if (jobExecutionContext.isRecovering()) {
loggerService.getLogger().debug("JobId {} is being recovered",job.getId());
undoPreparationState(job);
}
注意: - 作业需要几秒钟到几分钟才能执行。
When I am running two instances of the application in a machine. One of the instance picks up the job for execution and other instance picks up the same job for recovery.
As per the documentation, below property should take care of distributing the work across multiple instances. However, one of the instance is picking the same job for recovery.
org.quartz.jobStore.isClustered = true
Using Quartz-2.3.2
quartz.properties
org.quartz.scheduler.instanceId = AUTO
org.quartz.scheduler.instanceName = JobScheduler
org.quartz.threadPool.threadCount = 1
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass = org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.dataSource = ss
org.quartz.jobStore.isClustered = true
org.quartz.dataSource.ss.driver = com.mysql.jdbc.Driver
org.quartz.dataSource.ss.URL = jdbc:mysql://localhost:3306/ss
org.quartz.dataSource.ss.user = root
org.quartz.dataSource.ss.password = password
Code snippet to sscheduleJob
JobDetail jobDetail = JobBuilder
.newJob(JobService.class)
.requestRecovery(true)
.withIdentity(promotionJob.getId().toString(), RulesPromotionConstants.JOB_SCHEDULER_GROUP)
.build();
// see if jobdatamap needs to be added above
Trigger trigger = TriggerBuilder
.newTrigger()
.forJob(jobDetail)
.startAt(Date.from(Instant.ofEpochMilli(promotionJob.getScheduledAt())))
.withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow())
.withIdentity(promotionJob.getId().toString(), RulesPromotionConstants.JOB_TRIGGER_SCHEDULER_GROUP)
.build();
rulesPromotionScheduler.scheduleJob(jobDetail, trigger);
Below code snippet, if condition is being executed while the one of the instance is already executing the same job.
if (jobExecutionContext.isRecovering()) {
loggerService.getLogger().debug("JobId {} is being recovered",job.getId());
undoPreparationState(job);
}
Note:- The job takes few seconds to few minutes to execute.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论