读取器故障的Spring批量重试机制 [英] Spring batch retry mechanism for reader failure
问题描述
我有一个春季批处理作业,每天运行一次。我实现了读者,处理器和编写器。假设在运行读取器任务时发生任何异常,则整个作业将失败。我希望在5分钟后或立即重新运行失败工作的同一天。请告诉我如何在春季批量实施或向我提供任何有信息的示例代码或网站。
I have one spring batch job which will run daily once. I had implemented reader, processor and writer. Suppose if any exception happens while running reader task, then entire job will fail. I want to rerun same day for that failure jobs after 5 mins or immediately. Kindly let me know how i can implement in spring batch or provide me any sample code or website which have information.
推荐答案
拿一个请查看 Spring重试。它是作为Spring Batch的一部分开始的,但是从版本2.2.0开始,它已经转向独立项目(和依赖项)。
Take a look at Spring Retry. It started as part of Spring Batch but as of version 2.2.0 it has spined-off to a standalone project (and dependency).
能够以声明方式使用它是特别好:
Being able to use it declaratively is particularly nice:
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Retryable;
public interface MyExampleService {
@Retryable(maxAttempts = 3, backoff = @Backoff(delay = 2000))
String callService() throws Exception;
}
这篇关于读取器故障的Spring批量重试机制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!