Quartz 调度程序:集群 - 作业执行两次 [英] Quartz scheduler: clustering - job executing twice

查看:102
本文介绍了Quartz 调度程序:集群 - 作业执行两次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 Quartz 1.6.6 的 Java 应用程序.部署在Weblogic上,其架构包括两个应用服务器.

I have a Java application which utilises Quartz 1.6.6. It is deployed onto Weblogic, the architecture of which includes two application servers.

该应用程序包含一个定期运行的触发进程 - 每分钟一次.这是使用 Spring 3.1.1(带有 org.springframework.scheduling.quartz.SchedulerFactoryBean)实现的.

The application includes a trigger process which runs regularly - once a minute. This is achieved using Spring 3.1.1 (with a org.springframework.scheduling.quartz.SchedulerFactoryBean).

我在 Java 应用程序的 EAR 文件中包含了一个quartz.properties 文件,希望能够利用 Quartz 的集群设施,以便应用程序服务器能够自我同步,从而使作业每分钟只运行一次.但是,在查看应用程序日志时,很明显可以从生成的消息中看到,每 60 秒仍有两个作业在运行 - 一个比另一个晚了几秒钟.

I have included a quartz.properties file in the Java application's EAR file with a hope to be able to utilise Quartz's clustering facilities so that the application servers would synchronise themselves in order that the job is only run once per minute. However, on looking at the application log, it's obvious to see that from the messages produced, there are still two jobs being run every 60 seconds - one a few seconds behind the other.

令人困惑的是,我有另一个 Java 应用程序,我在其中包含了 Quartz 调度,而且它似乎运行得很愉快.另一个应用程序具有相同的机制,每分钟触发一次触发器,从日志中我可以看到该作业每 60 秒仅运行一次.

The confusing this is that I have another Java application into which I have included Quartz scheduling and it seems to be working quite happily. This other application has an identical mechanism for firing a trigger every minute and from the logs I can see that the job is only being run once every 60 seconds.

昨天下午作业运行的时间示例:

Examples of times yesterday afternoon that the job has run:

15:10:46,98415:10:49,58315:11:46,96115:11:49,561

15:10:46,984 15:10:49,583 15:11:46,961 15:11:49,561

这是我的quartz.properties 文件:

Here's my quartz.properties file:

org.quartz.scheduler.instanceName=QuartzClusteredScheduler
org.quartz.scheduler.instanceId=AUTO

org.quartz.threadPool.class=org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount=5

org.quartz.dataSource.dbDS.driver=oracle.jdbc.driver.OracleDriver
org.quartz.dataSource.dbDS.URL=jdbc:oracle:thin:@MY_DB:1521:my_sid
org.quartz.dataSource.dbDS.user=username
org.quartz.dataSource.dbDS.password=password

org.quartz.dataSource.dbDS.maxConnections=5

org.quartz.jobStore.class=org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate

org.quartz.jobStore.isClustered=true
org.quartz.jobStore.dataSource=dbDS
org.quartz.jobStore.tablePrefix=QRTZ_

我查看了数据库中特定于 Quartz 的表,但其中根本没有数据,这会让我认为由于某种原因没有获取属性文件.不过,我不明白为什么,因为我在 EAR 文件中的 WEB-INF/classes 下包含了quartz.properties.

I have had a look in the database at the Quartz-specific tables but there is no data at all in them, which would lead me to think that the properties file isn't being picked up for some reason. I can't see why, though, as I have included quartz.properties in the EAR file under WEB-INF/classes in the WAR.

在此先感谢您的帮助.

推荐答案

我使用了解决方法:在我的应用程序上下文 XML 文件中包含 SchedulerFactoryBean 定义中的属性,而不是使用quartz.properties.

I have utilised the workaround: include the properties within the SchedulerFactoryBean definition within my application context XML file, instead of using quartz.properties.

这篇关于Quartz 调度程序:集群 - 作业执行两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆