Results 1 to 3 of 3

Thread: Unable to run parallel step using <split>

  1. #1
    Join Date
    Oct 2010
    Posts
    5

    Post Unable to run parallel step using <split>

    Hi,
    I am newbie with spring batch. I am using Spring Batch 2.1.3 in my current project. I have use <split></split> to rum two parallel steps in job.
    But when I saw output of job, Steps are running in sequential manner (one after other)

    My helloWorldJob.xml is
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans" 
    	xmlns:batch="http://www.springframework.org/schema/batch"	
    	xmlns:aop="http://www.springframework.org/schema/aop"
    	xmlns:tx="http://www.springframework.org/schema/tx"
    	xmlns:p="http://www.springframework.org/schema/p"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xsi:schemaLocation="
    	http://www.springframework.org/schema/beans 
    	http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
    	http://www.springframework.org/schema/batch 
    	http://www.springframework.org/schema/batch/spring-batch-2.0.xsd
    	http://www.springframework.org/schema/aop 
    	http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
    	http://www.springframework.org/schema/tx 
    	http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
     
          
       <import resource="DB-JOBREPOSITORY.xml"/> 
     
        <bean id="hello" class="PrintTasklet">
            <property name="message" value="Hello"/>
        </bean>      
        <bean id="world" class="PrintTasklet">
            <property name="message" value=" World!"/>
        </bean>          
     
        <bean id="dynamicJobParameters"  class="DynamicJobParameters" /> 	
     
        <batch:job id="helloWorldJob"   incrementer="dynamicJobParameters">
         <batch:split id="main" >
         <batch:flow>
        	<batch:step id="step0" >
        		<batch:tasklet ref="hello" 
        		transaction-manager="jobRepository-transactionManager" />
        	</batch:step>
        	</batch:flow>
        	<batch:flow>    	
        	<batch:step id="step1">
        		<batch:tasklet ref="world" 
        		transaction-manager="jobRepository-transactionManager" />
        	</batch:step>
        	</batch:flow>
        	</batch:split>
        </batch:job>  
    </beans>
    and DB-JOBREPOSITORY.xml is
    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> 
     
    <bean id="jobRepository-dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">                  
    	<property name="driverClassName" value="com.ibm.db2.jcc.DB2Driver" />                
    	<property name="url" value="database" />                
    	<property name="username" value="username" />                
    	<property name="password" value="pasword" />   
    	    
    </bean>
    <bean id="jobRepository-transactionManager"  
    class="org.springframework.jdbc.datasource.DataSourceTransactionManager" lazy-init="true">
    <property name="dataSource"  ref="jobRepository-dataSource" />   
    </bean>
     
    	 
    <bean id="jobRepository" 
    class="org.springframework.batch.core.repository.support.JobRepositoryFactoryBean">
      <property name="dataSource" ref="jobRepository-dataSource" />
      <property name="transactionManager" ref="jobRepository-transactionManager"/>
      <property name="databaseType" value="db2" />
      <property name="tablePrefix" value="BATCH_"/>
    </bean>
    	
    <bean id="asyncTaskExecutor" 
    class="org.springframework.core.task.SimpleAsyncTaskExecutor"/>
    <bean id="syncTaskExecutor" 
    class="org.springframework.core.task.SyncTaskExecutor" />
     
    <bean id="jobLauncher" 
    class="org.springframework.batch.core.launch.support.SimpleJobLauncher">  
    	<property name="jobRepository" ref="jobRepository"/>			
    </bean>
    <bean id="jobExplorer" 
    class="org.springframework.batch.core.explore.support.JobExplorerFactoryBean" 
    p:dataSource-ref="jobRepository-dataSource" p:tablePrefix="batch_" />
    </beans>
    output of my sample project

    Code:
    Hello
    Hello
    Hello
    Hello
    Hello
     World!
     World!
     World!
     World!
     World!
    Please suggest.

    Thanks,

  2. #2
    Join Date
    Jun 2005
    Posts
    4,230

    Default

    Did you see the discussion of the task-executor attribute in the user guide (http://static.springsource.org/sprin...arallelSteps)?

  3. #3
    Join Date
    Oct 2010
    Posts
    5

    Default

    Quote Originally Posted by Dave Syer View Post
    Did you see the discussion of the task-executor attribute in the user guide (http://static.springsource.org/sprin...arallelSteps)?
    Thanks for Link

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •