【问题标题】:Grails Quartz Plugin concurrent not workingGrails Quartz 插件并发不工作
【发布时间】:2012-10-16 20:20:14
【问题描述】:

我无法让我在 Grails 中的 Quartz Job 按预期同时运行。这是我的工作的样子。我已经注释掉了使用 Executor 插件的行,但是当我不注释掉它们时,我的代码会按预期工作。

import java.util.concurrent.Callable

import org.codehaus.groovy.grails.commons.ConfigurationHolder

class PollerJob {

    def concurrent = true
    def myService1
    def myService2
    //def executorService

    static triggers = {
        cron name: 'pollerTrigger', startDelay:0, cronExpression: ConfigurationHolder.config.poller.cronExpression
    }

    def execute() {
        def config = ConfigurationHolder.config
        //Session session = null;
        if (config.runPoller == true) {
            //def result = executorService.submit({
                myService1.doStuff()
                myService2.doOtherStuff()
            //} as Callable)
        }
    }

}

在我的情况下,myService2.doOtherStuff() 需要很长时间才能完成,这与下次触发此作业时重叠。我不介意它们是否重叠,这就是我明确添加 def concurrent = true 但它不起作用的原因。

我有 0.4.2 版的 Quartz 插件和 Grails 1.3.7。我在这里做错了吗?似乎是一个非常简单易用的功能。我不反对使用 Executor 插件,但似乎我不应该这样做。

我不确定这是否重要,但在这种情况下,我从配置加载的 cronExpression 意味着每分钟执行一次该作业:“0 * * * * ?”

【问题讨论】:

    标签: grails quartz-scheduler


    【解决方案1】:

    显然,有一个我不知道的隐藏配置使它无法正常工作。在我的 conf 文件夹中有一个名为 quartz.properties 的文件,其中包含以下属性:

    org.quartz.threadPool.threadCount = 1

    增加这个数字后,我的作业即使没有完成上一次执行也会触发。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2016-07-07
      • 2014-01-07
      • 1970-01-01
      • 1970-01-01
      • 2016-02-21
      • 2014-03-07
      • 1970-01-01
      相关资源
      最近更新 更多