A framework for building batch jobs, or periodic processes that perform some action without direct user interaction. Very common use cases in ETLs, data processing and periodic housekeeping tasks, among others.
The main concepts in Spring Batch are a Job Launcher, Job, Job Repository, and Step. A Step in turn can comprise of ItemReaders, ItemProcessors and ItemWriters.
-
Job Launcher: Launches an instance of a Job.
-
Job: Represents the actual process to execute, consisting of one or more Steps.
-
Step: Particular phase of a Job.
-
Steps can contain ItemReader, ItemProcessor and ItemWriter elements, which can be thought of as data extractors, data transformers, and data sinks (loaders) respectively, using an ETL analogy.
-
-
Job Repository: Stores metadata relating to Job execution such as runtime, status and so on.
See this diagram for an illustration of the relationship between concepts:
The nice thing is that the Spring Batch model acknowledges the concept of having different instances of a Job, e.g. per day, as often times batch jobs are done daily and may need to be repeated for dates in the past.
Additionally, it provides production-quality features for tracking and monitoring the jobs including persisting job information to a repository, where developers need to provision the datastore/dataset but the persistence is provided out-of-the-box (appears to require a SQL repository). It also publishes metrics using micrometer for Job runs.