Job and Step Configuration Flashcards

(20 cards)

1
Q

How do you define a job in Spring Batch 3?

A

Using @Bean methods in a @Configuration class, defining a Job and its steps.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How do you create a step in Spring Batch 3?

A

By defining @Bean method returning a Step with a reader, processor and writer (or Tasklet).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a SimpleJobRepository?

A

A default implementation of JobRepository storing metadata in a database.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is ResourcelessTransactionManager?

A

A transaction manager used when no persistent job repository is required.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you start a job with parameters?

A

Using JobLauncher.run(job, new JobParametersBuilder().addString(“param”, “value”).toJobParameters()).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a JobExecutionListener?

A

A listener that executes code before and after a job runs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is a StepExecutionListener?

A

A listener that executes code before an after a step runs.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How do you ensure a job runs with unique parameters each time?

A

By using a timestamp or UUID as a job parameter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How can you enable restorability for a job?

A

By setting jobBuilder.preventRestart(false).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How do you configure a step to skip exceptions?

A

By using .faultTolerant().skip(Exception.class).skipLimit(5).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you configure a step with multiple readers and writers?

A

By using a CompositeItemReader and CompositeItemWriter.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a chunk-oriented processing model in Spring Batch?

A

A model where items are read, processed, and written in fixed-size chunks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the default commit interval in chunk processing?

A

1, meaning each item is processed and committed individually unless set otherwise.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How do you dynamically set the chunk size in a step?

A

By using StepExecutionListener to retrieve job parameters.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you configure an asynchronous step in Spring Batch?

A

By using a TaskExecuter with taskletStep().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a TaskletStep?

A

A step that executes a single task instead of chunk processing.

16
Q

How do you create a custom Tasklet?

A

By implementing the Tasklet interface and overriding exexute().

17
Q

What is the difference between TaskletStep and ChunkOrientedTasklet?

A

TaskletStep is for single-operation steps, while ChunkOrientedTasklet handles item-based processeing.

18
Q

How do you execute a tasklet step only once per job execution?

A

By setting allowStartIfComplete(false).

19
Q

How can you stop a step based on a condition?

A

By throwing a JobInterruptedException inside the step logic.