获取石英调度程序中的触发器计数? [英] get the count of trigger in quartz scheduler?
问题描述
我在我的应用程序中使用石英调度程序和 spring,我想获取触发器被触发时的执行次数(即第一次、第二次、第三次等等.我想获取已经执行的触发器的数量.有什么办法吗?提前致谢
I am using quartz scheduler along with spring in my application and i want to get the number of the execution when the trigger is fired (i.e) first time, second time, third time and so on. i want to get the number of trigger that has already executed. is there any way? thanks in advance
推荐答案
为了简单起见:如何向作业对象添加一个变量,该变量在每次作业执行时都被 ++ 处理?例如:
Just to keep it simple: how about adding a variable to the job object which is ++'ed every time that job executed? For example:
private AtomicInteger counter = new AtomicInteger(0);
public void run() {
counter.incrementAndGet();
...
}
public int getRunCount() {
counter.get();
}
除此之外 - 我认为 Quartz 中没有任何内部方法来跟踪作业运行的次数.
Other than that - I don't think there are any internal methods in Quartz to keep track of how many times the job ran.
这篇关于获取石英调度程序中的触发器计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!