Grails - Quartz作业触发器中的参数 [英] Grails - Parameter in a Quartz job Trigger
问题描述
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屋!