简体   繁体   English

Springboot Quartz:构建两个调度器(本地和集群)

[英]Springboot Quartz: Build two schedulers (local and clustered)

It's not clear to me which is the place where I need to set my scheduler properties.我不清楚哪个是我需要设置调度程序属性的地方。

I need to configure two schedulers:我需要配置两个调度器:

  • local当地的
  • clustered聚集的

How can I set a properties for my local and another properties for my clustered schedulers?如何为我的本地和集群调度程序设置另一个属性?

spring:
  datasource:
    ...
  quartz:
    job-store-type: jdbc
    properties:
      org.quartz.jobStore.isClustered: true
      org.quartz.scheduler.instanceId: AUTO

To run only one instance of the job you have to have an annotation @DisallowConcurrentExecution on Job class before creating JobDetail.要仅运行作业的一个实例,您必须在创建 JobDetail 之前在作业 class 上添加注释 @DisallowConcurrentExecution。 In this case JobDetail will be mark as Is_clustered in DB.在这种情况下,JobDetail 将在 DB 中标记为 Is_clustered。 Otherwise if you create JobDetail before adding an annotation then JobDetail stay nonClustered.否则,如果您在添加注释之前创建 JobDetail,则 JobDetail 保持非集群状态。 So I see a solution in separating Jobs and marking them with annotation while using JDBC jobs storing.所以我看到了一个解决方案,在使用 JDBC 作业存储时分离作业并用注释标记它们。

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

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