springBatch的一次实战案例

<bean id="initGoldBeanCustRepeatCheckDataTasklet" class="com.heng.group.biz.job.globalcustomer.check.InitGoldBeanCustRepeatCheckDataTasklet"/>
    <bean id="pendingCheckRepeatDataReader" class="org.springframework.batch.item.database.JdbcPagingItemReader">
   <property name="dataSource" ref="dataSource"/>
   <property name="queryProvider">
       <bean class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
           <property name="selectClause" value="select id,   member_id,   global_id,  company_name,   contact_name,   mobile_no,   phone_area,   phone_number,   fax_area,   fax_number,   email,   data_source, customer_type, status"/>
           <property name="fromClause" value="from pending_check_repeat_data"/>
           <property name="whereClause" value="where status=:status "/>
           <property name="sortKey" value="id"/>
       </bean>
   </property>
   <property name="parameterValues">
       <map>
           <entry key="status" value="new"/>
       </map>
   </property>
   <property name="pageSize" value="10000"/>
   <property name="rowMapper" >
       <bean class="com.heng.group.biz.job.globalcustomer.check.RepeatCheckItemMapper"/>
   </property>
    </bean>
    <bean id="goldBeanCustCheckItemProcessor"   class="org.springframework.batch.item.support.CompositeItemProcessor">
   <property name="delegates">
       <list>
           <bean class="com.heng.group.biz.job.globalcustomer.check.RepeatCheckMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.MemberIdMatcherProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.CompanyNameLikeMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.CompanyNameMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.ContactNameEmailMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.ContactNameMobileMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.ContactNamePhoneMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.FaxNumberMatchProcessor" />
           <bean class="com.heng.group.biz.job.globalcustomer.check.PhoneNumberMatchProcessor" />
       </list>
   </property>
    </bean>
    <bean id="repeatCheckStepTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor" scope="prototype">
<property name="corePoolSize" value="15"/>
<property name="maxPoolSize" value="20"/>
<property name="keepAliveSeconds" value="5"/>
<property name="queueCapacity" value="500"/>
</bean>
   <bean id="checkRepeatDataWriter" class="com.heng.group.biz.job.globalcustomer.check.RepeatCheckItemWriter" />
   <batch:job id="handleGoldBeanRepeatCheckJob" job-repository="jobRepository">
      <batch:step id="initGoldBeanCustCheckRepeatCheckStep"  >
         <batch:tasklet ref="initGoldBeanCustRepeatCheckDataTasklet" allow-start-if-complete="true">
            <batch:listeners>
                <batch:listener ref="initGoldBeanCustRepeatCheckDataTasklet"></batch:listener>
            </batch:listeners>
         </batch:tasklet>
         <batch:next on="COMPLETED-CONTINUE" to="processGoldBeanCustCheckRepeatCheckStep"/>
<batch:end on="COMPLETED-STOP"/>
     </batch:step>
     <batch:step id="processGoldBeanCustCheckRepeatCheckStep">
         <batch:tasklet task-executor="repeatCheckStepTaskExecutor" throttle-limit="10">
             <batch:transaction-attributes isolation="DEFAULT" propagation="REQUIRED" timeout="3000"/>
             <batch:chunk reader="pendingCheckRepeatDataReader" processor="goldBeanCustCheckItemProcessor" writer="checkRepeatDataWriter" retry-limit="2" skip-limit="1000" commit-interval="1"
              reader-transactional-queue="false">
              <batch:retryable-exception-classes>
<batch:include class="org.springframework.dao.OptimisticLockingFailureException" />
<batch:include class="org.springframework.dao.DeadlockLoserDataAccessException" />
 </batch:retryable-exception-classes>
              <batch:skippable-exception-classes>
<batch:include class="org.springframework.batch.item.validator.ValidationException" />
<batch:include class="org.springframework.transaction.CannotCreateTransactionException" />
</batch:skippable-exception-classes>
             </batch:chunk>
              <batch:listeners>
                <batch:listener ref="simpleStepListner"></batch:listener>
            </batch:listeners>
          </batch:tasklet>
      </batch:step>
      
      <batch:listeners>
  <batch:listener>
     <bean class="com.heng.group.biz.job.globalcustomer.check.RepeatJobCheckListener"/>
   </batch:listener>
 </batch:listeners>
   </batch:job>

你可能感兴趣的:(springbatch实战)