Grails - Quartz作业触发器中的参数 [英] Grails - Parameter in a Quartz job Trigger

查看:141
本文介绍了Grails - Quartz作业触发器中的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

def execute(){...}
}

我希望能够在 execute 块中提供的触发器中设置一个参数。
似乎我无法在 cron触发器中设置任何变量,并且自定义触发器需要执行 Quartz Trigger接口,我不知道该怎么做。

非常感谢任何帮助。

解决方案

让你的工作实现 StatefulJob ,那么你就可以访问 JobExecutionContext ,它有一个触发器实例访问器。如果你有自己的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.

解决方案

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.

这篇关于Grails - Quartz作业触发器中的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆