我无法让我的Quartz Job在Grails中按预期同时运行。这是我的工作。我已经注释了使用Executor插件的几行,但是当我不注释它们时,我的代码按预期工作。Grails Quartz插件并发不能正常工作
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 * * * *?”