简体   繁体   English

Spring boot 计划的 cron 作业在部署多个实例时运行 2 次

[英]Spring boot scheduled cron jobs run 2 times when deployed more than one instance

I have four cron jobs in the application and they work some hours in the day.我在应用程序中有四个 cron 工作,它们每天工作几个小时。 I deployed them in 6 different instance and I use shedLock to prevent overlapping but it wasn't enough.我将它们部署在 6 个不同的实例中,并使用 shedLock 来防止重叠,但这还不够。 Because sometimes job delay and lock is removed, then job work 2 times again.因为有时作业延迟和锁定被删除,然后作业再次工作 2 次。 How can I configure that if a cron job still working in the one instance, other instances don't start job till this one finish?如果一个 cron 作业仍在一个实例中工作,我该如何配置,其他实例在这个实例完成之前不会开始作业?

为什么不使用distribute executor?如果你部署在多个instance上,你必须管理和调度instance的状态,例如instance A在t1运行,instance B在t2运行,非常复杂。你可以部署在instance上或者选择distribute调度执行器,在所有分布式系统中,状态管理非常困难

尝试一次部署一个 Spring Boot Scheduled Cron 作业,以防止它们被部署多个实例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 创建两个作业时,Spring Boot @Scheduled 的 cron 作业无法正常工作 - Spring Boot @Scheduled's cron job doesn't work properly when created two jobs 当工作重叠时,spring @scheduled cron 的预期行为是什么? - What is the expected behaviour of spring @scheduled cron when jobs would overlap? Java Spring 引导计划作业 - Java Spring Boot scheduled jobs 在部署到 Azure 的 Spring Boot 应用程序中运行一次计划任务 - Run scheduled task once within Spring Boot app deployed to Azure Spring Boot 中的多线程 cron 作业 - Multithreading cron jobs in Spring Boot Spring计划的Cron工作在错误的时间解雇 - Spring Scheduled Cron jobs firing at wrong time 如何在 spring 中扩展 1 个以上的实例并处理计划任务? - How to scale more than 1 instance and deal with scheduled task in spring? Spring Scheduled Jobs在不同的池中执行3次 - Spring Scheduled Jobs executing 3 times in different pools 在tomcat7上以战争方式部署的Spring Boot应用程序失败,错误为“发现了多个名称为[org_apache_tomcat_websocket]的片段” - Spring boot app deployed as war on tomcat7 fails with error “More than one fragment with the name [org_apache_tomcat_websocket] was found” Spring @Scheduled(cron =“ 0 * * * *?”)不是每小时运行一次 - Spring @Scheduled(cron = “0 * * * * ?”) not run every hour
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM