我们使用Spring(4.0.3.RELEASE)+ Camel(2.13.4)+ Quartz2 + Oracle11开发了一个应用程序。我们正在使用JDK 1.6在Websphere 7上部署此应用程序。
我们有不同的垂直和水平聚类环境。在我们使用两台不同机器的地方,系统的时钟是同步的。所需的状态是让作业一次只在一台机器上运行。为此,我们使用以下属性将环境配置为群集。
org.quartz.scheduler.instanceName = UAT_CLUSTER
org.quartz.scheduler.instanceId = AUTO
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 1
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
org.quartz.jobStore.driverDelegateClass =
org.quartz.impl.jdbcjobstore.StdJDBCDelegate
org.quartz.jobStore.useProperties = false
org.quartz.jobStore.dataSource = oracleDs
org.quartz.jobStore.isClustered = true
org.quartz.dataSource.oracleDs.jndiURL = jdbc/oracleDs
我们看到的行为并不一致。在一个环境中,我们在同一台机器上 两个JVM ,我们看到 QRTZ_TRIGGERS表只有一个条目。
在另一个环境中, ,其中两台机器每个都有一个JVM ,行为有时类似,有时则不相似。我们看到 QRTZ_TRIGGERS表总是有一个,有时两个条目。
在这两种情况下,表格都会在触发时按预期更新。但是,这项工作并没有完成,而且日志甚至没有跟踪。
QRTZ_TRIGGERS 表格中的 SCHED_NAME 附加了 -camel-1 - * 。但是,行为并不一致。在我们有2台机器且每台机器都有一台JVM的环境中,我们看到只有一个SCHED_NAME被添加到 QRTZ_TRIGGERS 表中。在具有类似配置的另一个环境中,我们看到正在添加两个 SCHED_NAME 。
我们想知道表格的正确和预期行为以及实现这一目标的方法。任何指向表格文档的链接都将不胜感激。
路线很简单,定义为
@Configuration
@ComponentScan(basePackages = { "com.company.app.package" })
public class BatchConfig extends SingleRouteCamelConfiguration {
@Value("#{ systemProperties['application.environment'] }")
private String appEnv;
@Override
public RouteBuilder route() {
return new RouteBuilder() {
public void configure() {
from("quartzComponent://group/trigger?cron=0+0/5+*+?+*+*&recoverableJob=true").routeId("batchRoute")
.beanRef("firstProcessor").beanRef("secondProcessor").end();
};
};
}
@Override
protected void setupCamelContext(CamelContext camelContext) throws Exception {
camelContext.addComponent("quartzComponent", quartzComponent());
}
@Bean
public QuartzComponent quartzComponent() {
QuartzComponent quartz = new QuartzComponent();
quartz.setPropertiesFile("env/" + appEnv + "/quartz.properties");
return quartz;
}
答案 0 :(得分:0)
我能解决这个问题。问题在于孤儿线程。即使在关闭应用程序之后,我们也看到线程继续运行,并且QRTZ_SCHEDULER_STATE表将具有自服务器重启以来的所有先前实例。如果我删除这些条目,即使在关闭应用程序后,该表也会更新所有实例。
为了克服这些问题,我们使我们的根配置文件扩展了CamelConfiguration并使用了带注释的类,它扩展了RouteBuilder并被扫描为Spring Component。之前我们在配置中使用了SingleRouteCamelConfiguration。