grailsparametersquartz-schedulercrontriggermultitrigger

Grails - Parameter in a Quartz job Trigger


I have the following quartz job, set via Quartz-plugin:

class UserMonthlyNotificationJob { 
static triggers = {
        cron name:'dailyTrigger', cronExpression: " ... "
        cron name:'weeklyTrigger', cronExpression: " ... "
        cron name:'monthlyTrigger', cronExpression: " ... "
}

    def execute(){ ... }
}

I would like to be able to set a parameter in the trigger that would be available in the execute block. It seems I can not set any variable in a cron trigger, and a custom trigger require to implement the Quartz Trigger interface, which I do not know how to do.

Any help greatly appreciated.


Solution

  • Make your job implement StatefulJob, then you'll have access to JobExecutionContext which has a Trigger instance accessor. If you have your own Trigger class, that will be an instance of it.