Scrivio Interview library

Spring Batch

26 questions in 8 subtopics.

Jobs and steps

ConceptFoundations6 min read
In Spring Batch, explain the relationship between a Job, a JobInstance, a JobExecution, a Step and a StepExecution, using a nightly 'import-transactions' job run with a date parameter as the example.
CodingFoundations7 min read
Write the Java configuration for a Spring Batch 5 job with two steps: a chunk-oriented step that reads a CSV file and writes to a database, followed by a tasklet step that archives the file. Use Spring Boot auto-configuration.
DesignIntermediate7 min read
You need a batch flow that downloads a partner file, validates it, loads it, and then either publishes a summary or, if validation fails, notifies the partner and stops. Design the job flow in Spring Batch, including conditional transitions and exit statuses.
LeadershipAdvanced6 min read
Your organisation runs about 300 batch jobs across teams on a mix of cron scripts, an old enterprise scheduler and Spring Batch apps. You are asked to propose a standard batch platform. What would it include and how would you migrate?
LeadershipPrincipal6 min read
Batch jobs at your company are owned by whichever team wrote them years ago, and several critical end-of-day jobs now have no clear owner or on-call. As the senior technical leader, how do you fix batch ownership and decide what the batch platform should own versus the business teams?
LeadershipPrincipal6 min read
The business wants to move from nightly batch processing of transactions to near-real-time streaming. As the senior technical leader, how do you decide which batch workloads to convert and how to fund the change?

Chunk processing

InternalsFoundations7 min read
Describe what happens inside one chunk of a Spring Batch chunk-oriented step with a commit interval of 100, and what happens when the writer throws an exception on item 57 of that chunk in a fault-tolerant step with skip enabled.
ScenarioIntermediate6 min read
A Spring Batch step that loads 50 million rows takes 9 hours with a commit interval of 10. How would you tune it, and what trade-offs does each change bring?
DesignAdvanced6 min read
Several teams write batch jobs that update the same core customer database during the night and cause lock contention and replication lag. How would you set standards for chunk processing that protect shared databases?

Readers, processors and writers

ConceptFoundations6 min read
In Spring Batch, what does it mean when an ItemProcessor returns null, and how would you chain validation and transformation processors?
CodingFoundations7 min read
You need to read customers from a PostgreSQL table with 20 million rows in a Spring Batch step. Compare JdbcCursorItemReader, JdbcPagingItemReader and JpaPagingItemReader and pick one with reasons.
DebuggingIntermediate6 min read
A Spring Batch job writes to a database and also calls an external REST API in the ItemWriter. After a failure and restart, the external system has duplicate records. Why, and how would you redesign it?

Restartability

DebuggingFoundations6 min read
A Spring Batch job failed at 3 a.m. and the operator re-ran it with the same parameters, but it got JobInstanceAlreadyCompleteException. Another time the restart started reading the file from the beginning and created duplicates. Explain both behaviours.
DesignIntermediate6 min read
You are writing a custom ItemReader that reads from a paginated partner REST API in a Spring Batch job. How would you make the job restartable so it resumes from the last committed page?
ScenarioAdvanced6 min read
A regulator requires that your end-of-day settlement jobs can be safely re-run and their outputs audited. You own batch standards across 20 teams. What would you require for restartability and re-runs?

Partitioning and parallel steps

ConceptFoundations6 min read
Explain the difference between a multi-threaded step, parallel steps and partitioning in Spring Batch.
CodingIntermediate6 min read
Write the outline of a partitioned Spring Batch step that processes orders by id ranges across 8 worker threads, where each worker reads only its range.
DesignAdvanced7 min read
A month-end job processes 2 billion records and must finish within a 4-hour window. Local partitioning on one pod is not enough. How would you scale it out, and what are the risks?

Job repository

ConceptFoundations6 min read
What is stored in the Spring Batch job repository, and what problems do you see if you run batch jobs with an in-memory or resourceless repository in production?
DebuggingIntermediate6 min read
After a Kubernetes node was drained mid-run, a Spring Batch job shows status STARTED in the job repository forever, and new launches fail. What happened and how do you recover?
LeadershipPrincipal7 min read
Audit asks you to keep batch execution history for seven years, but the job repository tables have grown to hundreds of millions of rows and slow down launches. As the senior technical leader, how would you resolve the conflict between operations and compliance?

Job and step listeners

ConceptFoundations7 min read
Which listener types does Spring Batch offer, and what would you use each one for? Show how to register a listener on a step.
DebuggingIntermediate7 min read
A Spring Batch job reports COMPLETED even though a StepExecutionListener's afterStep found 30 percent of records invalid and was supposed to fail the step. The listener returns null. What is wrong, and how should the exit status drive the flow?
DesignAdvanced7 min read
Hundreds of batch jobs across teams need consistent run reports, metrics and alerting. Design how you would use Spring Batch listeners and other features to provide this as a platform capability.

Tasklet steps

CodingFoundations7 min read
Write a tasklet step in Spring Batch 5 that deletes staging files older than 7 days, and explain RepeatStatus.FINISHED versus CONTINUABLE.
ScenarioIntermediate8 min read
A tasklet step runs DELETE FROM audit_log WHERE created_at < now() - interval '1 year' and fails after 50 minutes with a transaction timeout, leaving locks and replica lag. How would you redesign it?