【问题标题】:best approach for Parallel threaded step in and multi step job spring batch并行线程步入和多步作业弹簧批处理的最佳方法
【发布时间】:2014-08-18 23:10:11
【问题描述】:

我有一个这样的作业配置,

工作(

   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>

我的问题是,

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

如果有更好的方法,请提出建议,

【问题讨论】:

    标签: spring spring-batch


    【解决方案1】:

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

    【讨论】:

    • 那没有锻炼,如果你注意到我上面的代码,taskexecutor 已经有注释行了。那不是拆分我作为参数添加给读者的列表。
    猜你喜欢
    • 2017-11-03
    • 2015-05-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多