当另一个cron任务失败时,cron任务会自动运行

时间:2018-10-22 07:57:04

标签: spring spring-boot cron cron-task crontrigger

我有多个cron任务,当一个cron任务在另一个cron任务失败时自动运行

@Scheduled(cron = "${cron.expressiom_report}") 
public void runReportCreationJob() throws Exception {
    JobParameters jobParameters = 
              new JobParametersBuilder()
              .addLong("time",System.currentTimeMillis()).toJobParameters();
    jobLauncher.run(ReportSchedulerConfiguration.job(), jobParameters);
}


@Scheduled(cron = "${cron.expression}")
public void runTicketJob() throws Exception {
    JobParameters jobParameters = 
              new JobParametersBuilder()
              .addLong("time",System.currentTimeMillis()).toJobParameters();
    jobLauncher.run(firstBatchConfiguration.job(), jobParameters);

@Bean(value = "Notify")
public Job job() {
    return jobBuilderFactorySla.get("Notify").incrementer(new RunIdIncrementer()).flow(step2()).end()
            .build();
}

@Bean
public Step step2() {
    return stepBuilderFactorySla.get("step2").tasklet(notify_alert()).build();

}

0 个答案:

没有答案