Spring - batch stream / split after step

I am creating a spring-batch solution that contains the following process:

step 1: split the list into several lists step 2: process each sub-list Step 3. Combine subscriptions

Generated sub-lists can be processed in parallel, and according to the spring-batch documentation this is supported. Unfortunately, I can only find spring-batch jobs that start with parallel steps, not examples that start in sequence.

The next task will not compile. Spring gives me an error message: 'cannot solve step2'

<batch:job id="webServiceJob2">
    <batch:step id="step1" next="step2"></batch:step>
    <batch:split id="step2" next="step3"></batch:split>
    <batch:step id="step3"></batch:step>
</batch:job>

So, how can I set up the task to complete one step first, than do several steps in parallel, and then run the last one step?

+4
source share
3 answers

I stumbled upon this question asking about how split works, and maybe this answer comes a little (one year) late, but here I go ...

The problem is that β€œsplit” is not one of the steps, but you called (and referenced) it as it is:

<batch:job id="webServiceJob2">
    <batch:step id="step1" next="step2"></batch:step>
    <batch:split id="step2" next="step3"></batch:split> <!-- This is not a step -->
    <batch:step id="step3"></batch:step>
</batch:job>

The correct syntax is:

<batch:job id="webServiceJob2">
    <batch:step id="step1" next="step2"></batch:step>
    <batch:split id="split_step2" next="step3">
        <flow> 
             <step id="step2_A_1" ... next="step2_A_2"/>
             <step id="step2_A_2" ... />
        </flow>
        <flow> 
             <step id="step2_B_1" ... />
        </flow>
    </batch:split>
    <batch:step id="step3"></batch:step>
</batch:job>

But this is not what you want to achieve, because in the declarations splityou must set the exact number of parallel steps that will be performed during compilation, and the purpose of the separation is to use different steps in each thread, invoking the same thing several times.

, .

+2

-, , .
.
, TaskExecutor bean, . TaskExecutors , TaskExecutor . Spring , .

0

, ! Spring Batch In Action (2012).

<batch:job id="importProductsJob">
  <batch:step id="decompress" next="readWrite">
    <batch:tasklet ref="decompressTasklet"/>
  </batch:step>
  <batch:split id="readWrite" next="moveProcessedFiles">
    <batch:flow>
      <batch:step id="readWriteBookProduct"/>
    </batch:flow>
    <batch:flow>
      <batch:step id="readWriteMobileProduct"/>
    </batch:flow>
  </batch:split>
  <batch:step id="moveProcessedFiles">
    <batch:tasklet ref="moveProcessedFilesTasklet" />
  </batch:step>
</batch:job>
0
source

All Articles