best approach for Parallel threaded step in and multi step job spring batch

戏子无情 提交于 2019-12-08 03:18:30

问题


I have a Job configuration like this,

JOB (

   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

)

Here is the code looks like,

<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>

My Question here is,

Do I have any other option other than writing Partitioner handler for second-step, I just want to know if there any way other than partitioning to achieve parallel processing in second step with that list of items.

Kindly suggest if there a better way,


回答1:


Try using one of task executor implementations supported in spring



来源:https://stackoverflow.com/questions/24458628/best-approach-for-parallel-threaded-step-in-and-multi-step-job-spring-batch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!