我正在使用grails quartz plugin在我们的应用中实施计划。我用QuartzConfig.groovy道具创建了一个调度程序,它是Clustered调度程序。我想在同一个应用程序中为非集群调度安排另外一个调度程序。
如何使用相同的grails quartz插件实现此目的。
答案 0 :(得分:0)
我这样做是在resources.groovy中创建一个新的调度程序bean:
newQuartzScheduler(org.springframework.scheduling.quartz.SchedulerFactoryBean) {
Properties properties = new Properties()
properties.setProperty('org.quartz.threadPool.threadCount', 5)
quartzProperties = properties
autoStartup = false
waitForJobsToCompleteOnShutdown = true
exposeSchedulerInRepository = false
jobFactory = ref('quartzJobFactory')
globalJobListeners = [ref("${SessionBinderJobListener.NAME}"), ref("${ExceptionPrinterJobListener.NAME}")]
}
并在BootStrap中添加以下代码。
newQuartzScheduler.addJob(grailsApplication.mainContext.getBean('org.com.jobs.JobNameJobDetail'), true)
newQuartzScheduler.start()
那个'细节'在作业名称是必要的,因为Quartz插件为每个作业创建一个bean,并在其名称中包含该后缀。
在我的情况下,我需要有一个不同的队列来执行我的一个工作。
quartz插件可在调度程序中添加所有作业。
如果您需要在两个调度程序中拥有所有作业,请参阅QuartzGrailsPlugin类中的doWithApplicationContext