您的位置:首页 > 其它

Quartz学习之Lesson7-TriggerListeners and JobListeners

2016-11-23 14:42 429 查看
Listener用来监听相关的event,并可以根据相应的event,采取不同的action。在Quartz中有两种形式的Listenter,一种是TriggerListeners,一种是JobListeners。

与Trigger相关联的事件包括:trigger firings, trigger mis-firings (discussed in the “Triggers” section of this document), and trigger completions (the jobs fired off by the trigger is finished)

与Job相关联的事件包括:a notification that the job is about to be executed, and a notification when the job has completed execution

Using Your Own Listeners

可以通过两种方式定义自己的Listener,一种是implement

TriggerListener and/or org.quartz.JobListener两个接口;一种是extends JobListenerSupport or TriggerListenerSupport

比如可以向Scheduler中注册这样的一个JobListener,用于监听名称为myJobName,group为myJobGroup的Job:

scheduler.getListenerManager().addJobListener(myJobListener, KeyMatcher.jobKeyEquals(new JobKey("myJobName", "myJobGroup")));
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  quartz