我使用这个插件:https://grails.org/plugin/quartz。是否有任何功能可将作业侦听器添加到作业?
最佳答案
ListenerManager listenerManager = scheduler.getListenerManager()
KeyMatcher<JobKey> matcher = KeyMatcher.keyEquals(jobDetail.key)
if (listenerManager.getJobListener(listener.getName()) == null) {
listenerManager.addJobListener(listener, matcher)
} else {
listenerManager.addJobListenerMatcher(listener.getName(), matcher)
}