Reputation: 862
I want to fetch a value from database and then set it as a value for repeatInterval for a job in Quartz plugin in grails. I did this as under.
class StartJob {
def interval = Settings.first().interval
static triggers = {
simple name: 'mySimpleTrigger', startDelay: 2000, repeatInterval:interval
}
def group = "MyGroup"
def execute(){
//do something
}
}
fetch a first row from table Settings
and then get its interval column and put it in the simple trigger. Now the problem is that the interval is non-static and triggers are static which gives errors due to mismatching. How can I handle this situation ? Is there any way to sort this out, trigger the job from somewhere else etc.. ?
Upvotes: 2
Views: 1279
Reputation: 1500
Is there any way to sort this out, trigger the job from somewhere else etc.. ?
Yes, you can schedule job manually like this:
MyJob.schedule(Long repeatInterval, Integer repeatCount?, Map params?)
See other examples here: http://grails-plugins.github.io/grails-quartz/guide/triggers.html
Upvotes: 1
Reputation: 885
class StartJob {
static def interval = Settings.getAll().get(0).interval static triggers = { simple name: 'mySimpleTrigger', startDelay: 2000, repeatInterval:interval } def group = "MyGroup" def execute(){ //do something } }
Upvotes: 1