Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

spring batch
framework
operations

What is a spring batch?

Yasir Latif

Overview

Spring batch is an open-source framework used to develop batch applications that are important for enterprise systems to perform daily operations. These operations include automatic and efficient processing of larger information, processing of repetitive tasks over larger data sets, and information integration received by different resources on a daily basis.

The architecture of spring batch

The spring batch has a layered architecture to ease the users as well as developers. The layered architecture of the spring batch with three high-level components is illustrated below:

Spring batch architecture

Application: All custom codes written using spring batch and all batch jobs are contained by the application layer.

Batch Core: The core functionality to launch a batch job is defined in batch core. The implementation of job-launcher, job, and test are included in it in the form of API classes.

Batch Infrastructure: The services that are used by application developers, as well as batch core, are defined in infrastructure core. The common services are itemReader, itemWriter, retryTemplates, etc.

Components of spring batch

The following illustration shows the connectivity of different components of batch spring with each other.

Spring batch components

JobLauncher: Triggers the job by reading job parameters and other information required to execute the job from the job repository. It provides an interface to launch the spring batch job.

Job: The batch process that is to be executed without any interruption is a job.

Step: A job is executed in single or multiple steps. The common steps to execute a job are defined in the batch core component illustration.

  • itemReader (reads data from a particular resource)
  • itemProcessor (processes data according to requirements)
  • itemWriter (writes data to an output source)

Job Repository: The CRUD operations for all three component's implementation, which means that jobLauncher, job, and step to maintain states, are provided by the job repository.

Advantages of spring batch

  • It provides flexibility to change or update a job execution sequence by changing the XML files only.
  • It provides easy maintenance as jobs are defined in steps and each step can be modified according to requirements.
  • If an error or exception is encountered, it has the ability to skip that job, or a retry mechanism can be implemented to retry to execute the job.
  • It has perfect logging and tracing mechanism.
  • It can automatically restart the job after multiple failures/exceptions.

RELATED TAGS

spring batch
framework
operations
RELATED COURSES

View all Courses

Keep Exploring