Grails - Parameter in a Quartz job Trigger

只愿长相守 提交于 2019-12-06 03:21:14

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.

Thank you very much, it did the trick. This is how I ended up using it:

import org.quartz.StatefulJob
import org.quartz.JobExecutionContext

class UserPeriodicalNotificationJob implements StatefulJob{   

    static triggers = {
        cron name:'dailyTrigger', cronExpression: ConfigHolder.config.userDailyNotificationJob
        cron name:'weeklyTrigger', cronExpression: ConfigHolder.config.userWeeklyNotificationJob
        cron name:'monthlyTrigger', cronExpression: ConfigHolder.config.userMonthlyNotificationJob   
    }

    void execute(JobExecutionContext context){
        def triggerName = context.trigger.key
        try {
            switch (triggerName) {...}
        }
        catch(Exception) {...}
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!