spring batch 3:Flow step简单介绍

简单的step无法满足我们的要求,比如优惠券到账业务。根据需求拆分为2部分,即到账业务与到账通知业务。那么我们需要先执行到账再执行通知,这里就需要用到Flow Step。
Flow Step的使用配置与一般的没什么不同唯一需要注意的是作为入口的job的地方。

<batch:job id="tranIntoAccountJob" restartable="true">
        
        <batch:flow id="doTranIntoFlow" parent="tranIntoFlow" />
    batch:job>
    <batch:flow id="tranIntoFlow" >
        
        <batch:step id="tranIntoMaster"  next="tranInfoDB"  >
            <batch:partition step="tranInfoDB" partitioner="tranIntoAccountPartitioner" >
                <batch:handler  grid-size="10" task-executor="taskExecutor"  />
            batch:partition>
            <batch:listeners  >
                <batch:listener ref="pickUpListener"  before-step-method="beforeStep"   />
            batch:listeners>
        batch:step>
        

        <batch:step id="tranInfoDB" next="tranInfoStep"  >
            <batch:tasklet transaction-manager="main_txManager">
                <batch:chunk reader="tranIntoAccountReader"  writer="tranIntoAccountWriter"   processor="tranIntoAccountProcessor"
                             commit-interval="100">
                batch:chunk>
            batch:tasklet>
        batch:step>

        
        <batch:step id="tranInfoStep" >
            <batch:tasklet transaction-manager="main_txManager" >
                <batch:chunk reader="tranIntoTemplateReader" writer="noticeInfoWriter" processor="tranIntoTemplateProcessor"
                             commit-interval="100" >
                batch:chunk>
            batch:tasklet>
        batch:step>
    batch:flow>
    
    <bean id="redExpireDetailListener" class="com.cwenao.cc.scheduler.batch.listener.RedExpireDetailListener" >
    bean>
附录
[IBM developerworks](http://www.ibm.com/developerworks/cn/java/j-lo-springbatch2/)
《Spring Batch in Action》

如有疑问请加公众号(K171),如果觉得对您有帮助请 github start
spring batch 3:Flow step简单介绍_第1张图片

你可能感兴趣的:(spring,batch)