Spring批处理并行执行多个步骤?
我已经为一个步骤实现了 spring 批处理分区,其中主步骤将其工作委托给多个并行执行的从属线程 . 如下图所示 . (参考Spring docs)
现在如果我有多个并行执行的步骤怎么办?如何在批量配置中配置它们?我目前的配置是
<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>
我的架构图应该如下图所示:
即使有可能使用 spring 批,我也不确定 . 任何想法或者我都想实现它 . 谢谢 .
回答(2)
我有类似的要求,并使用以下要求解决它
<batch:job id="cycleJob">
<batch:step id="zStep" next="gStep">
<batch:partition partitioner="zPartitioner">
<batch:step>
<batch:tasklet throttle-limit="1">
<batch:chunk processor="itemProcessor" reader="zReader" writer="itemWriter" commit-interval="1">
</batch:chunk>
</batch:tasklet>
</batch:step>
<batch:handler task-executor="taskExecutor" grid-size="${maxThreads}" />
</batch:partition>
</batch:step>
<batch:step id="gStep" parent="zStep" next="yStep">
<batch:partition partitioner="gPartitioner">
<batch:step>
<batch:tasklet throttle-limit="1">
<batch:chunk processor="itemProcessor" reader="gReader" writer="itemWriter" commit-interval="1">
</batch:chunk>
</batch:tasklet>
</batch:step>
<batch:handler task-executor="taskExecutor" grid-size="${maxThreads}" />
</batch:partition>
</batch:step>
</batch:job>
2 years ago
You can try the following.