在quartz插件中使用grails数据源
我想创建使用JdbcStore的quartz作业,如Burt示例中的集群部分所述 该示例显示如何使用quartz.properties文件配置quartz 现在,我希望我的jdbc存储与我的grails应用程序是同一个数据库,这样我就可以少复制一些设置 因此,假设我在数据库中手动创建所需的表,那么是否可以使用dataSource.groovy中配置的默认dataSource和quartz插件 我使用的是Grails2.4.4和quartz 1.0.2 换句话说,我可以将设置添加到QuartzConfig.groovy而不是创建一个新的quartz.properties文件吗?至少我可以从单独的环境设置中受益 这样的内容在QuartzConfig.groovy中有效吗在quartz插件中使用grails数据源,grails,quartz-scheduler,grails-plugin,Grails,Quartz Scheduler,Grails Plugin,我想创建使用JdbcStore的quartz作业,如Burt示例中的集群部分所述 该示例显示如何使用quartz.properties文件配置quartz 现在,我希望我的jdbc存储与我的grails应用程序是同一个数据库,这样我就可以少复制一些设置 因此,假设我在数据库中手动创建所需的表,那么是否可以使用dataSource.groovy中配置的默认dataSource和quartz插件 我使用的是Grails2.4.4和quartz 1.0.2 换句话说,我可以将设置添加到QuartzCo
quartz {
autoStartup = true
jdbcStore = true
waitForJobsToCompleteOnShutdown = true
exposeSchedulerInRepository = true
props {
scheduler.skipUpdateCheck = true
threadPool.class = 'org.quartz.simpl.SimpleThreadPool'
threadPool.threadCount = 50
threadPool.threadPriority = 9
jobStore.misfireThreshold = 60000
jobStore.class = 'impl.jdbcjobstore.JobStoreTX'
jobStore.driverDelegateClass = 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'
jobStore.useProperties = false
jobStore.tablePrefix = 'QRTZ_'
jobStore.isClustered = true
jobStore.clusterCheckinInterval = 5000
plugin.shutdownhook.class = 'org.quartz.plugins.management.ShutdownHookPlugin'
plugin.shutdownhook.cleanShutdown = true
jobStore.dataSource = 'myDS'
// [...]
}
我设法在QuartzConfig.groovy中调整了所有设置。我唯一需要删除的就是数据库特定的选项 此外,我还必须按照第12页的建议添加属性
scheduler.idleWaitTime=1000
,因为尽管我的作业被称为MyJob.triggerNow(paramsMap)
,但在实际启动之前有20到30秒的延迟
如果将scheduler.idleWaitTime
设置为1秒,作业确实会在提交后1秒触发
groovy实际上接受quartz配置文档中描述的所有属性(例如:)。只需将它们放在props{…}
块中,然后删除org.quartz
前缀
以下是我的最终配置,作为示例:
quartz {
autoStartup = true
jdbcStore = true
waitForJobsToCompleteOnShutdown = true
// Allows monitoring in Java Melody (if you have the java melody plugin installed in your grails app)
exposeSchedulerInRepository = true
props {
scheduler.skipUpdateCheck = true
scheduler.instanceName = 'my_reporting_quartz'
scheduler.instanceId = 'AUTO'
scheduler.idleWaitTime = 1000
threadPool.'class' = 'org.quartz.simpl.SimpleThreadPool'
threadPool.threadCount = 10
threadPool.threadPriority = 7
jobStore.misfireThreshold = 60000
jobStore.'class' = 'org.quartz.impl.jdbcjobstore.JobStoreTX'
jobStore.driverDelegateClass = 'org.quartz.impl.jdbcjobstore.StdJDBCDelegate'
jobStore.useProperties = false
jobStore.tablePrefix = 'QRTZ_'
jobStore.isClustered = true
jobStore.clusterCheckinInterval = 5000
plugin.shutdownhook.'class' = 'org.quartz.plugins.management.ShutdownHookPlugin'
plugin.shutdownhook.cleanShutdown = true
}
}
不要忘记使用适当的脚本创建sql表,它位于/path/to/your/project/target/work/plugins/quartz-1.0.2/src/templates/sql/…我可能错了,但是查看1.3的源代码。快照如果您在配置中完全忽略它,它将默认为您的应用程序
数据源。你可以考虑升级到这个版本。我仍然需要手工创建数据库表,对吗?我想是这样。查看插件的源代码,我没有看到任何其他说法。