并行螺纹步进和多步作业弹簧批的最佳方法

时间:2014-06-27 18:28:43

标签: spring spring-batch

我有这样的工作配置,

工作(

   Step 1: Read from DB (JDBC Item Reader + Writer) 
   Keep the list of items in Job Execution Context


    Step 2  Take Items (list) from Step 1 (from Job Context) 
    and execute this Step 2 in multiple parallel processes

以下是代码,

<bean id="webServiceReader" class="org.springframework.batch.item.adapter.ItemReaderAdapter" scope="step">
            <property name="targetObject" ref="individualXXXXService"/>
            <property name="targetMethod" value="execute"/>
            <property name="arguments">
              <list>
                    <value type="java.util.List">#{jobExecutionContext['JDBC_ITEMS']}</value>
              </list>
            </property>
        </bean>
<batch:job id="identityCpiIborSync" restartable="true">

                <batch:step id="fetchCustomers" next="fetchDatabase">
                    <batch:tasklet>
                        <batch:chunk reader="dbItemReader"  writer="dbItemWriter" commit-interval="500"/>
                    </batch:tasklet>
                    <batch:listeners>
                        <batch:listener ref="stepScopeExecutionListener"/>
                    </batch:listeners>
                </batch:step>

                <batch:step id="updateWS">
                    <!-- <batch:tasklet task-executor="taskExecutor" throttle-limit="10"> -->
                    <batch:tasklet>
                        <batch:chunk reader="webServiceReader"  writer="cpiWSItemWriter" commit-interval="10"/>
                    </batch:tasklet>
                </batch:step>

                <batch:listeners>
                    <batch:listener ref="batchJobListener" />
                </batch:listeners>

            </batch:job>

我的问题是,

除了为第二步编写分区程序处理程序之外,我还有其他选项吗?我只想知道除了分区之外是否还有其他方法可以在第二步中使用该项目列表实现并行处理。

请建议是否有更好的方法,

1 个答案:

答案 0 :(得分:-1)

尝试使用spring支持的任务执行器实现之一

相关问题