Hello,
We are facing a behaviour that we cannot understand. In the code bellow, that's the parent step our test step. We've created 3 kinds of exceptions:
- Fatal Exceptions: if a reader, processor, writer throws that exceptions, the batch is immediately in failure
- Ignorable Exceptions: the batch can retry to re-process, or re-write, the skip policy returns true for that kind of exceptions
- Non ignorable exception: the batch can retry, but the skip policy doesn't skip these exceptions.
The "timeoutRetryPolicy" and "attemptsCounterRetryPolicy" are provided by Spring Batch (org.springframework.batch.retry.policy.TimeoutRet ryPolicy and org.springframework.batch.retry.policy.SimpleRetry Policy) while "exceptionsFilterRetryPolicy" is our own retry policy. It's used to returns false to fatal exceptions, otherwise true. The default skip policy skips ignorable exceptions and doesn't skip non ignorable exceptions.Code:<bean id="abstractGenericStep" class="org.springframework.batch.core.step.item.FaultTolerantStepFactoryBean" abstract="true"> <property name="transactionManager" ref="transactionManager" /> <property name="jobRepository" ref="jobRepository" /> <property name="backOffPolicy" ref="timeIntervalPolicy" /> <property name="retryPolicy"> <bean id="defaultRetryPolicy" class="org.springframework.batch.retry.policy.CompositeRetryPolicy"> <property name="policies"> <set> <ref bean="timeoutRetryPolicy" /> <ref bean="attemptsCounterRetryPolicy" /> <bean id="exceptionsFilterRetryPolicy" class="com.bsb.sf.batch.service.exception.ExceptionsFilterRetryPolicy"> <property name="batchExceptionManager" ref="batchExceptionManager" /> </bean> </set> </property> </bean> </property> <property name="skipPolicy" ref="defaultSkipPolicy" /> <property name="allowStartIfComplete" value="false" /> </bean>
We have a commit-interval of 5. The first five items are written correctly. We throw an exception when the batch writes the 6th and 7th items. That exception is a fatal exception. So, the batch must stop, unfortunately, the processor is called to process the 6th. A RetryExhaustedException is thrown after its process and the batch is stopped.
Is our configuration correct ?


Reply With Quote