简体   繁体   English

Spring Quartz Scheduler 在 ECS 集群中不起作用

[英]Spring Quartz Scheduler not working in ECS Cluster

I am working on a scheduling application using Spring Boot(2.2.7.RELEASE) , Quartz Scheduler(2.3.2) .我正在使用Spring Boot(2.2.7.RELEASE)Quartz Scheduler(2.3.2) 开发调度应用程序。 Application deployed in AWS ECS Cluster and running in multiple EC2 instances based on the load.应用程序部署在AWS ECS 集群中,并根据负载在多个 EC2 实例中运行 I am using the AWS RDS Mysql database and created required quartz tables.我正在使用AWS RDS Mysql数据库并创建了所需的石英表。 I have used the following properties file for quartz.我为石英使用了以下属性文件。

quartz.properties -石英.properties -

org.quartz.scheduler.instanceName = MyClusteredScheduler
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 25
org.quartz.threadPool.threadPriority = 5
org.quartz.jobStore.misfireThreshold = 60000
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = true
org.quartz.jobStore.clusterCheckinInterval = 20000

Application Starting log -应用程序启动日志 -

2020-10-13 23:33:02.853  INFO 938 --- [           main] org.quartz.core.QuartzScheduler          : Quartz Scheduler v.2.3.2 created.
2020-10-13 23:33:02.856  INFO 938 --- [           main] o.s.s.quartz.LocalDataSourceJobStore     : Using db table-based data access locking (synchronization).
2020-10-13 23:33:02.858  INFO 938 --- [           main] o.s.s.quartz.LocalDataSourceJobStore     : JobStoreCMT initialized.
2020-10-13 23:33:02.859  INFO 938 --- [           main] org.quartz.core.QuartzScheduler          : Scheduler meta-data: Quartz Scheduler (v2.3.2) 'quartzScheduler' with instanceId 'NON_CLUSTERED'
Scheduler class: 'org.quartz.core.QuartzScheduler' - running locally.
NOT STARTED.
Currently in standby mode.
Number of jobs executed: 0
Using thread pool 'org.quartz.simpl.SimpleThreadPool' - with 10 threads.
Using job-store 'org.springframework.scheduling.quartz.LocalDataSourceJobStore' 
- which supports persistence. and is not clustered.

Problem is multiple EC2 instances are picking up the same job at same time.问题是多个 EC2 实例同时执行相同的工作。 Because of that getting the wrong result.因为得到了错误的结果。

Can somebody please let me know what I am missing here?有人可以让我知道我在这里缺少什么吗? What I need to do here to make it work in the ECS cluster.我需要在这里做些什么才能让它在 ECS 集群中工作。 Every time when the Spring application is getting started getting, it's showing the log message is not clustered.每次启动 Spring 应用程序时,它都显示日志消息未聚集。

This's been resolved.这已经解决了。 I have added the following configuration details to the application.properties file and removed the quartz.properties file我已将以下配置详细信息添加到application.properties文件并删除了quartz.properties文件

spring.quartz.job-store-type = jdbc
spring.quartz.properties.org.quartz.scheduler.instanceName = MyClusteredScheduler
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.scheduler.instanceId = AUTO
spring.quartz.properties.org.quartz.jobStore.useProperties = true
spring.quartz.properties.org.quartz.jobStore.tablePrefix = QRTZ_
spring.quartz.properties.org.quartz.jobStore.isClustered = true
spring.quartz.properties.org.quartz.jobStore.clusterCheckinInterval = 20000

Now the batch job is working fine in ECS and at a time only one job is running in the ECS cluster.现在批处理作业在 ECS 中运行良好,并且一次只有一个作业在 ECS 集群中运行。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM