以下代码的目的是发送电子邮件,如果发送失败,请尝试N次,在此问题中,我将其设置为100,以便可以在应用程序服务器重新启动时测试简历。
JobDetail job = newJob(RetryJobWrapper.class)
.storeDurably()
.requestRecovery(true)
.withIdentity("resetPassword", "emailJobs")
.withDescription("An important job that fails with an exception and is retried.")
.usingJobData(RetryJobWrapper.WRAPPED_JOB_KEY, EmailJob.class.getName())
// Set defaults - can be overridden in trigger definition in schedule file
.usingJobData(RetryJobWrapper.MAX_RETRIES_KEY, "100")
.usingJobData(RetryJobWrapper.RETRY_DELAY_KEY, "2")
.build();
Trigger trigger = newTrigger()
.withIdentity("resetPasswordTrigger", "emailJobs")
.startNow()
.withSchedule(simpleSchedule())
.build();
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.scheduleJob(job, trigger);
在boostrap servlet中,我有以下代码:
private void configureJobScheduler() {
try {
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.start();
scheduler.resumeAll();
} catch (SchedulerException e) {
e.printStackTrace();
}
}
问题是,即使我已设置scheduler.resumeAll();
作业也无法恢复。例如,在重试期间(例如在100次重试的中间),我重新启动了应用程序服务器,作业没有恢复,可能丢失了什么?