Usage of SimpleLimitExceptionHandler
Hi,
I have some doubts regarding the usage of SimpleLimitExceptionHandler. When i configured one as follows:
Code:
<bean id="txload" class="org.springframework.batch.execution.step.SimpleStepConfiguration">
<property name="commitInterval" value="10"></property>
<property name="startLimit" value="100"/>
<property name="saveRestartData" value="true" />
<property name="allowStartIfComplete" value="false" />
<property name="tasklet">
<bean class="org.springframework.batch.execution.tasklet.RestartableItemProviderTasklet">
<property name="itemProvider">
<bean class="org.springframework.batch.item.provider.InputSourceItemProvider">
<property name="inputSource" ref="txInputSource" /><!--This is a JdbcCursorInputSource-->
</bean>
</property>
<property name="itemProcessor">
<bean class="com.iflexsolutions.wm.infra.test.item.processor.TxProcessor">
<!--A class which implements ItemProcessor-->
</bean>
</property>
</bean>
</property>
<property name="exceptionHandler">
<bean class="org.springframework.batch.repeat.exception.handler.SimpleLimitExceptionHandler">
<property name="limit" value="5"/>
<property name="type" value="java.lang.Exception"/>
<property name="useParent" value="true"/>
</bean>
</property>
</bean>
I have coded the TxProcessor to just output a log regarding processing. And to selectively throw new Exception() for certain ids(for 5 ids : 15,16,17,18,19)of the data obtained.
What has been observed is:
The first time i run the job, in which the above config is a step, when it encounters id 15, it tries to reexecute that chunk(commitInterval being 10) 5 times, throws the exception and the step fails.
The second time i execute the same job, the processing picks up 15,16,17,18,19 (the same is logged) and it successfully completes the step and eventually the job execution.
Is it because of the the tasklet being a RestartableItemProviderTasklet used together with SimpleLimitExceptionHandler.
Please throw more light on this behaviour.
Regards,
Bhramara