Spring Batch Architecture

Spring Batch is designed to support extensibility so as to make the development of Batch applications easy for developers. The figure below shows three major high-level components of Spring Batch: Application, Core, and Infrastructure.



Application: The Application component contains all batch jobs and custom code which are written using Spring Batch.


Core: The Core component contains implementations of JobLauncher, Job, and Step. It also contains runtime classes required for launching and managing batch jobs.

Infrastructure: The Infrastructure component provides common readers, writers and services which are used by Core Framework and custom code in the form of ItemReader and ItemWriter.


Key Principle to consider when building a batch application

We should keep the following things in mind before building a batch application:

  • Minimize use of too many input/output operations that may increase use of system resources.
  • Keep processing and storing of data physically close to each other.
  • Try to keep the logical structures as simple as possible in a single batch application.
  • Avoid processing of same data twice.
  • Validate the data after processing to maintain data integrity.
  • Perform stress-testing on production like environment data.
  • Allocate enough memory before running the batch application in order to avoid reallocation of memory during processing as it will be time consuming.
  • Make use of internal memory to perform as many operations as possible.
  • The deployment file of spring batch application is usually a Jar file built using maven or gradle.