If you are using Spring Batch
prior of version 2.2.0
then use the Retry
functionality included in the Spring Batch library.
As noted in the beginning of the above quoted Spring Batch documentation page for Retry:
The retry functionality was pulled out of Spring Batch as of 2.2.0. It is now part of a new library, Spring Retry.
Otherwise use directly the Spring Retry directly (spinoff the Spring Batch project) that is adding some nice declarative way to annotate the functionality you need:
@Service
class MyService {
//...
@Retryable(maxAttempts=5, backoff=@Backoff(delay=100, maxDelay=500))
public myFunctionalityService() {
// ...
}
// ...
}