Results 1 to 3 of 3

Thread: job enters infinite loop

  1. #1
    Join Date
    Jul 2010
    Posts
    2

    Default job enters infinite loop

    I have defined a job with custom item reader, writer and processor. It doesn't do much, just dummy things, but it enters an infinite loop. In the log I see that after an item writer finishes the execution, the item reader is directly called; in other words the steps repeats again and again and never finishes. I cannot figure out what should be done in order to make a step complete.

    These are job configurations:
    Code:
    	<batch:job id="myJob" >
    	  <batch:step id="myStep" >
    	    <batch:tasklet >
    	      <batch:chunk reader="myReader" processor="myProcessor" writer="myWriter" commit-interval="1" />
    	    </batch:tasklet
    	  </batch:step>
    	</batch:job>
    
        <bean id="jobLauncher" class="org.springframework.batch.core.launch.support.SimpleJobLauncher">
            <property name="jobRepository" ref="jobRepository"/>
        </bean>
    	
    	<bean id="transactionManager" class="org.springframework.batch.support.transaction.ResourcelessTransactionManager"/>
    	
    	<bean id="jobRepository"
    		class="org.springframework.batch.core.repository.support.MapJobRepositoryFactoryBean">
    		<property name="transactionManager" ref="transactionManager"/>
    		<property name="isolationLevelForCreate" value="ISOLATION_DEFAULT"/>
    	</bean>
    Reader, Processor, Writer:
    Code:
    public class DummyReader implements ItemReader < String > {
       public String read ( ) {
         return "dummy";
       }
    }
    
    public class DummyProcessor implements ItemProcessor < String, String> {
    
    	public String process ( String item ) throws Exception {
    		//do nothing
    		return item;
    	}
    }
    
    public class DummyWriter implements ItemWriter < String > {
    	public void write ( List < ? extends String > items ) throws Exception {
                //do nothing
           }
    }
    Thnx
    Last edited by meremortal; Jul 2nd, 2010 at 04:22 AM.

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

    Default

    Your ItemReader doesn't follow the contract from the interface (http://static.springsource.org/sprin...temReader.html).
    Last edited by Dave Syer; Jul 5th, 2010 at 06:37 AM. Reason: Updated URL link

  3. #3
    Join Date
    Jul 2010
    Posts
    2

    Default

    Thanks Dave. It wasn't obvious to me when I was reading the user guide and I made a different assumption about the way it should work; and I did not look into the api docs.

Posting Permissions

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