问题描述
我正在从远程主机上的目录传输文件,当此作业的间隔到达时,触发器会触发作业.但我想确定,如果在触发时作业仍在存储上工作(下载尚未完成的文件)点火时间到了,石英要跳过这个间隔.我尝试使用这个c r on_trigger.MISFIRE_INSTRUCTION_DO_NOTHING 但我似乎只适用于没有可用线程的情况.
I am transferring files from a directory on a remote host and a trigger fires jobs when interval arrives for this job.But i want be sure that if a job still working on a storage (downloading of files not yet finished) when trigger fire time arrives ,quartz going to skip this interval.I try to use thisc r on_trigger.MISFIRE_INSTRUCTION_DO_NOTHING but i seems it only for if there is no available thread for job.
public CronTrigger scheduleJob(RemoteJob job, String cronExpression,Date firstFireTime) throws SchedulerException, ParseException {
JobDetail jobDetail = new JobDetail(job.getDescription(), job.getName(), job.getClass());
CronTrigger crTrigger = new CronTrigger(
"cronTrigger", job.getName(), cronExpression);
scheduler.scheduleJob(jobDetail, crTrigger);
crTrigger.setStartTime(firstFireTime);
crTrigger.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
return crTrigger;
}
推荐答案
创建一个 TriggerListener 来跟踪您的一个下载作业是否正在运行,然后返回 true 以否决其他类型的作业的执行.
Create a TriggerListener that tracks if one of your download jobs is running, and and then return true for vetoing the execution of the other type of job.
这篇关于如何跳过cron触发器触发时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!