其一直以来我用石英很长一段时间,但我会设法在历时job listeners注册听两个不同的组
的基本思路应该从一个组/列表(“todayGroup”)开始一个工作,'(“todayGroup”)作业监听器检测完成的好坏。然后开始列表中的下一项工作。但是,它将“刚完成”作业保存在(“tomorrowGroup”)下的调度程序中。
public class MyTodayGroupListener extends JobListenerSupport {
private String name;
private static String GROUP_NAME = "todayGroup";
public MyOtherJobListener(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public void jobWasExecuted(JobExecutionContext context,
JobExecutionException jobException) {
Scheduler sched = context.getScheduler();
// switch the job to the other group so we don't run it again today.
JobDetail current = context.getJobDetail();
JobDetail tomorrows = current.getJobBuilder().withIdentity(current.getKey().getName(), "tomorrow").build();
sched.addJob(tomorrows,true);
//see if there is anything left to run
Set<JobKey> jobKeys = sched.getJobKeys(groupEquals(GROUP_NAME));
Iterator<JobKey> nextJob = null;
if(jobKeys != null && !jobKeys.isEmpty()){
nextJob = jobKeys.iterator();
}
if(nextJob != null){
// Define a Trigger that will fire "now" and associate it with the first job from the list
Trigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startNow()
.forJob(nextJob =.next())
.build();
// Schedule the trigger
sched.scheduleJob(trigger);
}
}
}
同样,你需要两个“组触发”,将在您需要的特定时间火从各自小组的第一份工作。