Spring Batch Core Concepts: Job, Step, Chunk, and Tasklet
Fast recall
Quick revision
Core answer
Whether the candidate understands Spring Batch's execution model and the JobRepository persistence layer before writing any code
Confusing Tasklet with Chunk — candidates often think Tasklet is just a simpler Step, not realizing they are mutually exclusive execution strategies within a Step
Mention JobRepository, JobInstance vs JobExecution, and StepExecution as the persistence layer that enables restartability — most candidates skip this entirely
Interview-ready guide
Interview answer
Spring Batch structures batch processing around a clear hierarchy: Job, Step, and either Chunk or Tasklet at the step level. Every layer is persisted to the JobRepository, which is what makes restart and audit possible.
The hierarchy
- Job — the overall batch process, like 'import monthly invoices'; composed of one or more Steps in sequence or conditionally
- Step — one phase of the job; each Step has its own execution status and can be restarted independently
- Chunk — the read-process-write model for a step; reads N items, processes each, writes the batch — all inside one transaction
- Tasklet — a single operation for a step; not a read-process-write loop;
execute()returnsRepeatStatus.FINISHED
JobRepository — the persistence layer
- Stores
JobInstance(logical job run identified by Job name + JobParameters) - Stores
JobExecution(one physical attempt at the JobInstance) - Stores
StepExecution(per-step state plus serialized ExecutionContext for restart) - Spring Boot auto-configures it from the application's
DataSource
Chunk transaction model
- Chunk size 100 means: read 100 records, process each, write all 100 in one transaction
- A write failure rolls back only that chunk — already committed chunks are not re-processed on restart
- Larger chunks: fewer transactions, better throughput; smaller chunks: finer-grained checkpointing
Tasklet vs Chunk
- Chunk model is for streaming work — rows in a table, lines in a file
- Tasklet is for one-shot work — truncating a table, sending a notification, calling a stored procedure
- They are mutually exclusive within a single Step
In an interview, I'd emphasize the JobRepository — most candidates skip it, but it's what makes Spring Batch suitable for production rather than a hand-rolled loop.
Spring Batch Core Concepts: Job, Step, Chunk, and Tasklet
Direct Answer
A Job is the top-level container representing an entire batch process, composed of one or more Steps executed in sequence or conditionally. Each Step follows either a chunk-oriented model (read-process-write in fixed-size chunks inside one transaction) or a Tasklet model (a single custom unit of work). The JobRepository persists every JobInstance, JobExecution, and StepExecution to a relational database, which is what enables restartability, audit trails, and skip/retry tracking — features that distinguish Spring Batch from a hand-rolled batch loop.
Common Mistakes & Pitfalls
Confusing Tasklet with Chunk — candidates often think Tasklet is just a simpler Step, not realizing they are mutually exclusive execution strategies within a Step
Check your understanding
Answer these without looking back at the article.
- How does Spring Batch decide whether a failed job can be restarted versus re-run from scratch?
- What happens if two instances of the same Job are launched simultaneously with the same parameters?
- When would you choose a Tasklet over a chunk-oriented Step in production?
- Which BATCH_* tables does Spring Batch read on restart to determine where to resume?
Related interview prep categories
1Looking for a structured roadmap?
Every module on this page is also part of the full Java backend interview track.