Job and Step Configuration Flashcards
(20 cards)
How do you define a job in Spring Batch 3?
Using @Bean methods in a @Configuration class, defining a Job and its steps.
How do you create a step in Spring Batch 3?
By defining @Bean method returning a Step with a reader, processor and writer (or Tasklet).
What is a SimpleJobRepository?
A default implementation of JobRepository storing metadata in a database.
What is ResourcelessTransactionManager?
A transaction manager used when no persistent job repository is required.
How do you start a job with parameters?
Using JobLauncher.run(job, new JobParametersBuilder().addString(“param”, “value”).toJobParameters()).
What is a JobExecutionListener?
A listener that executes code before and after a job runs.
What is a StepExecutionListener?
A listener that executes code before an after a step runs.
How do you ensure a job runs with unique parameters each time?
By using a timestamp or UUID as a job parameter.
How can you enable restorability for a job?
By setting jobBuilder.preventRestart(false).
How do you configure a step to skip exceptions?
By using .faultTolerant().skip(Exception.class).skipLimit(5).
How do you configure a step with multiple readers and writers?
By using a CompositeItemReader and CompositeItemWriter.
What is a chunk-oriented processing model in Spring Batch?
A model where items are read, processed, and written in fixed-size chunks.
What is the default commit interval in chunk processing?
1, meaning each item is processed and committed individually unless set otherwise.
How do you dynamically set the chunk size in a step?
By using StepExecutionListener to retrieve job parameters.
How do you configure an asynchronous step in Spring Batch?
By using a TaskExecuter with taskletStep().
What is a TaskletStep?
A step that executes a single task instead of chunk processing.
How do you create a custom Tasklet?
By implementing the Tasklet interface and overriding exexute().
What is the difference between TaskletStep and ChunkOrientedTasklet?
TaskletStep is for single-operation steps, while ChunkOrientedTasklet handles item-based processeing.
How do you execute a tasklet step only once per job execution?
By setting allowStartIfComplete(false).
How can you stop a step based on a condition?
By throwing a JobInterruptedException inside the step logic.