A lot of corporate applications need bulk processing to carry out business operations in mission-critical settings. These business operations include:
- Automated processing of large volume of data that is best done without user interaction.
- Periodic processing of complex business rules over large data set on a regular basis.
- Integration of data received from various internal and external systems, which typically requires validations and formatting and processing in a transactional manner.
Spring Batch is a lightweight, comprehensive batch framework that is designed to develop robust batch applications. It is build upon the characteristics of the Spring Framework.
Spring batch provides reusable function for processing large volume of data, including logging/tracing, transaction management, job processing statistics, job restart, skip and resource management. It also provides features to process extremely high-volume and high performance batch jobs through optimization and portioning techniques.
Spring batch can be used in various use cases such as reading flat files and inserting to database, moving high volume of data from one database to other, transforming it in between two steps.
Spring Batch Architecture
Spring Batch is designed with extensibility and a diverse group of end users in mind. The figure below shows the layered architecture that supports the extensibility and ease of use for end-user developers.
Fig: Spring Batch Layered Architecture
This layered architecture highlights three major high-level components: Application, Core, and Infrastructure. The application contains all batch jobs and custom code written by developers using Spring Batch. The Batch Core contains the core runtime classes necessary to launch and control a batch job. It includes implementations for JobLauncher, Job, and Step. Both Application and Core are built on top of a common infrastructure. This infrastructure contains common readers and writers and services (such as the RetryTemplate), which are used both by application developers(readers and writers, such as ItemReader and ItemWriter) and the core framework itself (retry, which is its own library).
In this article, we learned about the basics of spring batch, what it is used for and what can we do with it. In coming articles we will learn about the implementation of spring batch jobs.