如何防止在Grails中同时执行作业? [英] How to prevent concurrent execution of a job in Grails?
问题描述
(当然,整个魔法可以用一个静态易失标志完成,但不是一个很好的方法)
(我怎样才能配置这个工作是单身?)
thx
def concurrent = false
从Quartz插件文档:
lockquote
默认情况下,作业是以并发方式执行的,所以如果你想重写这个行为,你可以使用'concurrent'属性,在这种情况下,Quartz的StatefulJob将被使用
I have a quartz job in grails, that needs to be executed in every 5s, but I need this sequentially. In some situations the execution of the job exceeds this 5s, in this case I dont't want to be executed while the previouse exection is not finished. How to configure this in grails?
(Of course the whole magic could be done with a static volatile flag, but is not a very elegant way to do this) (Also how can I configure for the job to be singleton?)
thx
Assuming that you're using the grails quartz plugin, you should just be able to add this to your job:
def concurrent = false
From the Quartz Plugin Documentation:
"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. If you want to override this behavior you can use 'concurrent' property, in this case Quartz's StatefulJob will be used"
这篇关于如何防止在Grails中同时执行作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!