-
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
-
Your ItemReader doesn't follow the contract from the interface (http://static.springsource.org/sprin...temReader.html).
-
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.