1
votes

I am trying to see if the following can done in Spring Batch. A Step is invoked for one ItemReader/Processor/Writer. Before this step completes,can the next Step(with its own Reader/Processor/Writer) be invoked for some processing and then return to the previous step.

To be more clear, in the processor of the first step I am putting a List into the executionContext hoping for the process in the second step to pick it up for further processing after which the program goes back to the processor of the first step to build a list and set it into the context again for it to be picked up by the second step so on and so forth.

1

1 Answers

0
votes

It looks to me as if you are trying to do something, which spring-batch is not meant for.

First, spring-batch processes every step completely. Only then, the next step is executed. You can start two steps in parallel, but then, they have different inputs and produce different outputs.

Moreover, your approach to put "business"-data into the executionContext and use it as a transport-container between steps, is strange as well.

Generally, a "normal" reader-processor-writer step works the following way: 1. it reads a chunk of entries from the source 2. it processes every read item of the chunk individually in the processor 3. it writes the whole chunk to the target 4. it starts with the next chunk with step 1 5. after the reader has read all available items, the job advances to the next step.

It would probably help, if you explain, what your final goal is. As far as I see, I'm afraid you are going down the wrong track.

Could it be, that you are trying to group items together? There are solutions for that.