0
votes

I have some confusion regarding @StepScope in chunk-oriented processing:

I have, lets say, 2 million record to read. So I want to run my spring batch application in chunks. Lets say 2000 items to read, and process and write, then go and read 2001th till 4000th item, process, write, etc.

Question is, if I don't use @StepScope, the batch will know that it has to read 2001st item, and not reread what it already has read?

1

1 Answers

1
votes

Yes, even without using @StepScope the reader will read the next chunk and not re-read the same chunk again.

The scope step is actually required in order to use late binding of attributes from the job/step execution context. More details on this here: https://docs.spring.io/spring-batch/4.0.x/reference/html/step.html#late-binding

So if your reader does not need to access job parameters or attributes from the job/step execution context, it does not need to be step scoped and will still read data chunk by chunk. In sum, there is no relation between step scope and chunk-oriented processing.