问题描述
我使用grails 在我们的应用程序中实施日程安排。我用QuartzConfig.groovy props创建了一个调度器,这是一个集群调度器。我希望在同一个应用程序中有一个调度程序用于非集群调度。
I am using grails quartz plugin to implement scheduling in our app. I've created one scheduler with QuartzConfig.groovy props, which is Clustered scheduler. I want one more scheduler in the same app for Non-Clustered scheduling.
如何使用相同的grails quartz插件实现此目的。
How can I achieve this using same grails quartz plugin.
推荐答案
我在resources.groovy中创建一个新的调度器bean:
I do this creating a new scheduler bean in resources.groovy:
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中添加下面的代码。
and add the below code in BootStrap.
newQuartzScheduler.addJob(grailsApplication.mainContext.getBean('org.com.jobs.JobNameJobDetail'), true)
newQuartzScheduler.start()
工作名称中的'详细信息'是必需的ry,因为Quartz插件为每个作业创建一个bean,并且在他的名字中包含该后缀。
That 'Detail' in job name is necessary because Quartz plugin create a bean for each job and it includes that suffix at his names.
在我的情况中,我需要一个不同的队列来执行其中一个我的工作。
In my case, I need to have a different queue to execute only one of my jobs.
石英插件添加您调度程序中的所有工作。
The quartz plugin add all jobs in your scheduler.
如果您需要拥有所有两个调度程序中的作业都可以在QuartzGrailsPlugin类中看到doWithApplicationContext
If you need to have all your jobs in both schedulers see doWithApplicationContext in QuartzGrailsPlugin class
这篇关于使用圣杯石英插件的多个调度程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!