Top Frequently asked Spring Batch Interview Questions
- Q: What is Spring Batch?
- Q: What is Spring Batch Admin?
- Q: Where batch processing is used?
- Q: What is the Basic Structure of Spring Batch?
- Q: What is Job?
- Q: What is Step in job?
- Q: What is JobLauncher?
- Q: What is ItemReader?
- Q: What is ItemProcessor?
- Q: What is ItemWriter?
- Q: How to configure the job in Spring Batch?
- Q: What is batch processing architecture?
- Q: What is spring batch listener?
- Q: What is difference between Step, Chunk and Tasklet?
- Q: What is execution context in Spring Batch?
- Q: What is StepScope in Spring Batch?
- Q: What is Job Repository in Spring Batch?
- Q: What is Step Partition in Spring Batch?
- Q: What is Spring batch job launcher?
- Q: What is remote chunking in Spring Batch?
- Q: What is difference between Remote Partitioning and Remote Chunking in Spring Batch?
- Q: What is Skip limit in Spring Batch?
- Q: What is JobBuilderFactory in Spring Batch?

Q: What is Spring Batch?
Ans:
Spring Batch is an open source,lightweight framework for batch processing by performing a series of jobs. It allows processing of bulk data in a transactional manner and execute day to day activity with precision and speed.
Q: What is Spring Batch Admin?
Ans:
Admin has a web based UI, and spring batch console. It is an application built on the web, open source based on Spring MVC.
Q: Where batch processing is used?
Ans:
It is commonly used in enterprise applications where large volumes of data are used to perform. For example, large data are tested regularly in enterprise applications.
Checkout our related posts :
Q: What is the Basic Structure of Spring Batch?
Ans:
The following figure shows the different components of Spring Batch and how they are connected with each other.
Q: What is Job?
Ans:
A Job is the batch process to be executed in a Spring Batch application without interruption from start to finish.
This Job is further broken down into steps.
A Job is made up of many steps and each step is a READ-PROCESS-WRITE task or a single operation task (tasklet).
Q: What is Step in job?
Ans:
Spring Batch Step is an independent part of a job. As per above Spring Batch structure diagram, each Step consist of an ItemReader, ItemProcessor (optional) and an ItemWriter. Note: A Job can have one or more steps.
Q: What is ItemReader?
Ans:
An ItemReader reads data into a Spring Batch application from a particular source.
Q: What is ItemWriter?
Ans:
ItemWriter writes data from the Spring Batch application to a particular destination.
Q: What is ItemProcessor?
Ans:
After reading the input data using itemReader, ItemProcessor applies business logic on that input data and then writes to the file / database by using itemWriter.
Q: What is Job Repository in Spring Batch?
Ans:
Job Repository is used to persist all meta-data related to the execution of the Job.
JobRepository Configuration:
<job-repository id="jobRepository"
data-source="dataSource"
transaction-manager="transactionManager"
table-prefix="SAMPLE_BATCH_"
max-varchar-length="1500"/>
- id: Mandatory field to provide id value.
- data-source: Can be configured to point to the database to be used for storing batch meta-data entities.
- transaction-manager: Entity to handle transaction management
- table-prefix: The Spring Batch meta-data are stored in tables starting with 'SPRING_BATCH_' as the prefix.
Q: How to configure the job in Spring Batch?
Ans:
There are many ways we can configure the Sprin Batch Job. We are using here builder abstract way to call the jobs. Job needs JobRepository to configure the job. If you see below Job has three steps to load the notes, to load the task and to process those
tasks.
@Bean
public Job employeeJob() {
return this.jobBuilderFactory.get("notesJob")
.start(LoadNotes())
.next(LoadTasks())
.next(processTasks())
.end()
.build();
}
Q: What is batch processing architecture?
Ans:
Job has complete batch process and one or more steps are included in the job. A job set up to run in JSL (Job Specification Language) sequence.
Q: What is spring batch listener?
Ans:
Listeners are the entities that help intercept a job or a step execution that allows the user to perform some functionality.
Q: What is difference between Step, Chunk and Tasklet?
Ans:
Spring batch reads an input, processes based on business logic, then aggregates the chunk of data output to a destination (file or database) and eventually writes it out. It's the most common way to perform a step.
Q: What is execution context in Spring Batch?
Ans:
In case you want to restart a batchrun for error like fatal exception, the Spring Batch continues with the stored ExecutionContext.
Q: What is StepScope in Spring Batch?
Ans:
The objects whose scope is StepScope, for those objects Spring Batch will use the spring container to create a new instance of that object for each step execution.
Q: What is Step Partition in Spring Batch?
Ans:
Spring batch can be handled in a single-process job, however to have a multi-process job, we can use Partitioning a Step. In Spring Batch Step Partitioning, Step is divided into a number of child steps, which may be used either as remote instances or as local execution threads.
Q: What is Spring batch job launcher?
Ans:
Spring batch job launcher is an interface for running the jobs, which uses run method with two parameters.
Example:JobLauncher jobLauncher = context.getBean(JobLauncher.class);
Job testJob = context.getBean(TestJob.class);
jobLauncher.run(
testJob,
new JobParametersBuilder()
.addString("inputFile", "file:./notes.txt")
.addDate("date", new Date())
.toJobParameters()
);
Q: What is remote chunking in Spring Batch?
Ans:
In spring batch remote chunking, Master Step reads the date and pass over to slaves for processing.
Q: What is difference between Remote Partitioning and Remote Chunking in Spring Batch?
Ans:
Both Partitioning is master-slave based proceess, however below is the difference between them.
- Remote Partitioning : In this it allows data to be partitioned and executed parallely. For example, we can say partition is divided into set of data, like if have 30 rows, so first data set would 1-10 rows, second data set will have 11-20 and so on.. Master Step have all meta data like all partition data sets and slave executes those meta data and send result back to master for aggregation.
- Remote Chunking : In Remote Chunking, Master Step read the data and has control to pass the data to its Slaves for processing. Once slaves process data,the result of the ItemProcessor is returned to the master for writing.
Q: What is Skip limit in Spring Batch?
Ans:
Spring batch skips the items,once it reaches the maximum skip limit. The will automatically failed the batch jobs based on spring batch skip limit.
Q: What is JobBuilderFactory in Spring Batch?
Ans:
It create job builder and initializes it's job repository
JobBuilderFactory(JobRepository jobRepository)