Class RepeatTemplate

java.lang.Object
org.springframework.batch.repeat.support.RepeatTemplate
All Implemented Interfaces:
RepeatOperations
Direct Known Subclasses:
TaskExecutorRepeatTemplate

public class RepeatTemplate extends Object implements RepeatOperations
Simple implementation and base class for batch templates implementing RepeatOperations. Provides a framework including interceptors and policies. Subclasses just need to provide a method that gets the next result and one that waits for all the results to be returned from concurrent processes or threads.
N.B. the template accumulates thrown exceptions during the iteration, and they are all processed together when the main loop ends (i.e. finished processing the items). Clients that do not want to stop execution when an exception is thrown can use a specific CompletionPolicy that does not finish when exceptions are received. This is not the default behaviour.
Clients that want to take some business action when an exception is thrown by the RepeatCallback can consider using a custom RepeatListener instead of trying to customise the CompletionPolicy. This is generally a friendlier interface to implement, and the RepeatListener.after(RepeatContext, RepeatStatus) method is passed in the result of the callback, which would be an instance of Throwable if the business processing had thrown an exception. If the exception is not to be propagated to the caller, then a non-default CompletionPolicy needs to be provided as well, but that could be off the shelf, with the business action implemented only in the interceptor.
Author:
Dave Syer