我使用这个插件:https://grails.org/plugin/quartz。是否有任何功能可将作业侦听器添加到作业?

最佳答案

你可以看看https://github.com/grails-plugins/grails-quartz/blob/master/src/main/groovy/quartz/QuartzGrailsPlugin.groovy#L256-L269

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)
}

10-04 17:29