How to prevent concurrent execution of a job in Grails?

后端 未结 4 1212
长情又很酷
长情又很酷 2021-02-19 05:12

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 d

4条回答
  •  时光说笑
    2021-02-19 06:02

    At the and I implemented it without quartz, using spring tasks:

    beans = { 
        xmlns task: "http://www.springframework.org/schema/task"
    
        task.'scheduler'('id':"myScheduler", 'pool-size':"1")
    
        task.'scheduled-tasks'('scheduler':"myScheduler") {
            task.'scheduled'(ref:"myBean", method:"myBeanMethodToExec", 'fixed-delay':5000)
        }
    }
    

    (pool-size 1 I think is even not necessary, but to be sure 100% ;))

提交回复
热议问题