Multiple scheduler with Grails Quartz plugin

无人久伴 提交于 2019-12-11 07:52:20

问题


I have an application using Grails Quartz plugin. I need to have two jobs to have multiple instances running, but have separate limitation on number of threads to be used for each job. As far as I understand, I need separate Thread Pools, which is possible by having separate schedulers. However, I cannot figure out how to create multiple schedulers with Quartz plugin.


回答1:


Assuming you want to use different triggers to start the job multiple times. this works for me.

class MyJob {

    static triggers = {
        cron name: 'trigger1', cronExpression: "0 30 12 ? * WED"
        cron name: 'trigger2', cronExpression: "0 30 12 ? * SAT"
    }

    def execute() {

        // execute task, do your thing here
        println "Job executed"
    }
}

Finally, about concurrent tasks. This is from the plug-in page:

By default Jobs are executed in concurrent fashion, so new Job execution can start even if previous execution of the same Job is still running.




回答2:


Quartz plugin 2.0.13

According to the official documentation :

Multiple triggers per job are allowed.

For instance,

class MyJob {
  static triggers = {
    simple name:'simpleTrigger', startDelay:10000, repeatInterval: 30000, repeatCount: 10
    cron name:'cronTrigger', startDelay:10000, cronExpression: '0/6 * 15 * * ?'
    custom name:'customTrigger', triggerClass:MyTriggerClass, myParam:myValue, myAnotherParam:myAnotherValue
  }


来源:https://stackoverflow.com/questions/6362058/multiple-scheduler-with-grails-quartz-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!