【问题标题】:Where does Spring Batch saves the batch execution state?Spring Batch 在哪里保存批处理执行状态?
【发布时间】:2017-11-22 13:20:15
【问题描述】:

我有一个需要很长时间才能执行的春季批处理作业。执行了一段时间后,我决定要停止它,但是每当我重新启动服务器时,该作业在服务器恢复后仍会继续执行。

我想知道 Spring Batch 将状态保存在哪里,以便我可以删除它并阻止这种情况发生。

我发现有些属性可以配置为无法重新启动作业,我将继续使用它,但现在我只需要确保作业可以永久停止。

【问题讨论】:

    标签: spring spring-batch batch-processing


    【解决方案1】:

    您可以查看文档 here,其中显示并描述了 Spring Batch 元数据表。

    【讨论】:

      【解决方案2】:

      如果您只是想防止重新启动以下配置的作业应该会对您有所帮助。 preventRestart() 有助于避免重新启动作业

      https://docs.spring.io/spring-batch/trunk/apidocs/org/springframework/batch/core/job/builder/JobBuilderHelper.html

      @Bean
              public Job myJob(JobBuilderFactory jobs) throws Exception {
                  return jobs.get("myJob")
                          .flow(step1())                          
                          .build()                
                          .preventRestart()
                          .build();
      
              } 
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-25
        • 2018-12-16
        • 2016-08-15
        • 2021-09-27
        • 1970-01-01
        • 2012-09-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多