带有 Grails Quartz 插件的多个调度程序

发布于 2024-11-15 17:53:11 字数 133 浏览 5 评论 0 原文

我有一个使用 Grails Quartz 插件的应用程序。我需要有两个作业才能运行多个实例,但对每个作业使用的线程数有单独的限制。据我了解,我需要单独的线程池,这可以通过单独的调度程序来实现。但是,我不知道如何使用 Quartz 插件创建多个调度程序。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

老子叫无熙 2024-11-22 17:53:11

假设您想使用不同的触发器多次启动作业。这对我有用。

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"
    }
}

最后,关于并发任务。
这是来自插件页面:

默认情况下,作业以并发方式执行,因此新作业
即使先前执行过同一作业,也可以开始执行
仍在运行。

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.

雨巷深深 2024-11-22 17:53:11

Quartz插件2.0.13

根据官方文档

每个作业允许多个触发器。

例如,

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
  }

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
  }

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文