当前位置:   article > 正文

Quartz定时任务执行抛异常,重新执行_定时任务抛出异常还会再次执行吗

定时任务抛出异常还会再次执行吗
@Component
@DisallowConcurrentExecution
@CronExp(id = 2,cron = "0/30 * * * * ?")
public class TestJob implements Job {

    @SaIgnore
    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {

        try {
            String[] str = {"1223",null,"212","333"};
            for (String s : str) {
                s.equals("sss");//模拟空指针异常
            }
        } catch (Exception e) {
            e.printStackTrace();
            JobExecutionException e2 = new JobExecutionException(e);
            e2.setRefireImmediately(true);//重新执行
            try {
                Thread.sleep(2000);
                System.out.println(LocalDateTime.now()+"   **********");
            } catch (InterruptedException ex) {
                ex.printStackTrace();
            }
            throw e2;
        }
        System.out.println("定时任务2执行了******");
    }
}
<!--Quartz定时依赖-->
<dependency>
    <groupId>xin.altitude.cms</groupId>
    <artifactId>ucode-cms-quartz</artifactId>
    <version>1.5.3.1</version>
</dependency>

java quartz 失败重试_Quartz 2 定时任务(三):异常与中断处理 - 锐洋智能 - 博客园

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/Cpp五条/article/detail/83628
推荐阅读
相关标签
  

闽ICP备14008679号