This module provides framework code for the Spring Batch project. The core interfaces are ItemReader, ItemProcessor, ItemWriter, RepeatOperations and RetryOperations.

The reader and writer interfaces are implemented in some generic ways to help users with I/O in a transactional envionment. Spring Batch provides some file-based (flat file and xml) implementations and some database implementations.

The main implementations of the repeat and retry interfaces are RepeatTemplate and RetryTemplate. Example usage:

RepeatTemplate template = new RepeatTemplate();

template.setCompletionPolicy(new FixedChunkSizeCompletionPolicy(2));

template.iterate(new RepeatCallback() {

    public RepeatStatus doInIteration(RepeatContext context) {
        // Do stuff in batch...
        return RepeatStatus.CONTINUABLE; // Return RepeatStatus.FINISHED to signal exhausted data


The callback is executed repeatedly, until the completion policy determines that the batch should end (in the example, twice).

The framework provides RetryOperations for automatic retry of a business operation. This is independent of the batching support, but will often be used in conjunction with it. Example usage:

RetryTemplate template = new RetryTemplate();

template.setRetryPolicy(new TimeoutRetryPolicy(30000L));

Object result = template.execute(new RetryCallback() {

    public Object doWithRetry(RetryContext context) {
        // Do stuff that might fail, e.g. webservice operation
        return result;