I have implemented spring batch partitioning for a single steps where a master step delegates its work to several slave threads which than gets executed in parallel. As shown in following image.(Reference Spring docs) Now what if I have multiple steps which are to be executed in parallel? How to configure them in batch configuration? My current configuration is
<batch:job id="myJob" restartable="true" job-repository="jobRepository" >
<batch:listeners>
<batch:listener ref="myJoblistener"></batch:listener>
</batch:listeners>
<batch:step id="my-master-step">
<batch:partition step="my-step" partitioner="my-step-partitioner" handler="my-partitioner-handler">
</batch:partition>
</batch:step>
</batch:job>
<batch:step id="my-step" >
<batch:tasklet ref="myTasklet" transaction-manager="transactionManager" >
</batch:tasklet>
<batch:listeners>
<batch:listener ref="myStepListener"></batch:listener>
</batch:listeners>
</batch:step>
My architecture diagrams should be like following image:
I am not sure even if it is possible using spring batch.Any ideas or I am way over my head to implement it.Thank you.
You can try the following.
<batch:job id="myJob" restartable="true" job-repository="jobRepository" >
<batch:listeners>
<batch:listener ref="myJoblistener"></batch:listener>
</batch:listeners>
<batch:step id="my-master-step">
<batch:partition step="my-step" partitioner="my-step-partitioner" handler="my-partitioner-handler">
</batch:partition>
</batch:step>
</batch:job>
<batch:step id="my-step" >
<batch:job ref="MyChildJob" job-launcher="jobLauncher"
job-parameters-extractor="jobParametersExtractor" />
<batch:listeners>
<batch:listener ref="myStepListener"></batch:listener>
</batch:listeners>
</batch:step>
<batch:job id="MyChildJob" restartable="false"
xmlns="http://www.springframework.org/schema/batch">
<batch:step id="MyChildStep1" next="MyChildStep2">
<batch:tasklet ref="MyChildStep1Tasklet" transaction-manager="transactionManager" >
</batch:tasklet>
</batch:step>
<batch:step id="MyChildStep2" next="MyChildStep3">
<batch:tasklet ref="MyChildStep2Tasklet" transaction-manager="transactionManager" >
</batch:tasklet>
</batch:step>
<batch:step id="MyChildStep3">
<batch:tasklet ref="MyChildStep3Tasklet" transaction-manager="transactionManager" >
</batch:tasklet>
</batch:step>
</batch:job>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With