【问题标题】:Quartz dont recover Job石英不恢复工作
【发布时间】:2018-03-06 15:36:39
【问题描述】:

我用:

  • 春季 4.2.9
  • PostgreSQL
  • 石英 2.3.0
  • Java 8

我在集群服务器中的恢复工作遇到了一些问题...我在集群中有 2 台测试服务器(1 个 DB)。

调度程序工作正常,但是当我停止运行 Job 的 tomcat (1) 时,另一台服务器 (2) 上的作业无法恢复...

如果我重新启动 tomcat #2,则调度程序开始工作,如果我启动 tomcat #1,当 tomcat #2 工作时,quartz 将工作交给 tomcat #1。效果很好,但是

第一个问题:我需要当 tomcat #1 停止时,tomcat #2 将启动 Job 而无需重新启动...

第二个问题:jdbcjobstore 更适合我吗? JobStoreTX 还是 JobStoreCMT ?在工作集群中,我在 Spring 4.2.9 上有 4 台服务器

对不起我的英语,非常感谢你的回答!

我的项目中的属性 Quartz、@Bean

Properties prop = new Properties();
prop.put("org.quartz.threadPool.class","org.quartz.simpl.SimpleThreadPool");
prop.put("org.quartz.threadPool.threadCount", "4");
prop.put("org.quartz.jobStore.misfireThreshold", "20000");
prop.put("quartz.scheduler.instanceName", "ServerScheduler");
prop.put("org.quartz.scheduler.instanceId", "AUTO");
prop.put("org.quartz.scheduler.skipUpdateCheck", "true");
prop.put("org.quartz.scheduler.instanceId", "IS_CLUSTERED");
prop.put("org.quartz.scheduler.jobFactory.class","org.quartz.simpl.SimpleJobFactory");
prop.put("org.quartz.jobStore.class","org.quartz.impl.jdbcjobstore.JobStoreCMT");
prop.put("org.quartz.jobStore.driverDelegateClass","org.quartz.impl.jdbcjobstore.PostgreSQLDelegate");
prop.put("org.quartz.jobStore.dataSource", "myDS");
prop.put("org.quartz.jobStore.nonManagedTXDataSource", "myDS");
prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_");
prop.put("org.quartz.jobStore.isClustered", "true");
prop.put("org.quartz.dataSource.myDS.driver", "org.postgresql.Driver");
prop.put("org.quartz.dataSource.myDS.URL", url);
prop.put("org.quartz.dataSource.myDS.user", user);
prop.put("org.quartz.dataSource.myDS.password", password);
prop.put("org.quartz.dataSource.myDS.maxConnections", "4");

我的工作和触发器

JobDetail job = newJob(QuartzStockTask.class)
                .withIdentity("Job " + "1", "Job group " + "11")
                .requestRecovery(true)
                .build();

Trigger sTrigger1 = newTrigger()
                .withIdentity("Trig " + "1", "Trig group " + "11")
                .startNow()
                .withSchedule(simpleSchedule()
                        .withIntervalInSeconds(10)
                        .repeatForever())
                .build();

scheduler.scheduleJob(job, sTrigger1);

【问题讨论】:

  • 我第一次使用 JobStoreTX 时遇到同样的问题,我尝试使用 JobStoreCMT,但没有帮助...
  • 您是否使用“org.quartz.jobStore.clusterCheckinInterval”的默认值?这决定了实例签入的频率。如果您的设置中此值较大,则服务器 2 可能尚未检测到服务器 1 已关闭。
  • 我尝试了您的解决方案,但没有帮助

标签: java spring postgresql scheduled-tasks quartz-scheduler


【解决方案1】:

我发现了问题,它是双 org.quartz.scheduler.instanceId,第一次是 AUTO,第二次是 IS_CLUSTERED。 谢谢大家!

【讨论】:

猜你喜欢
  • 2013-10-16
  • 1970-01-01
  • 1970-01-01
  • 2018-08-18
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-14
  • 2019-06-20
相关资源
最近更新 更多