My batch application is pretty simple - input is a flat file, outputs: database and error file for wrong records. On write phase I can receive normal DB exception like DataIntegrityViolationException, process it and then rethrow again to rollback DB transaction. I need to skip incorrect records and do not try to retry them (to avoid wrong data in error file and log). Now I have a problem trying to configure retry behavior of SkipLimitStepFactoryBean - every time it retries each wrong record exactly two times. I tried to set retryLimt to 0, 1, even -1, tried to configure retryPolicy as NeverRetryPolicy - everything the magic two attempts were performed.
If you have any idea what's whrong please help. I do not want to keep workaround I have (manual transaction control in writer) to make all the app behavior configurable.
<bean id="simpleStep" class="org.springframework.batch.core.step.item.SkipLimitStepFactoryBean"
<property name="itemKeyGenerator"><bean class="my.company.batch.ItemKeyGenerator"/></property>
<property name="transactionManager" ref="rlTransactionManager" />
<property name="jobRepository" ref="jobRepository" />
<property name="commitInterval" value="1" />
<!-- setting skip limit to a maximum number of record in the file -->
<property name="skipLimit" value="30000"/>
<property name="retryPolicy"><bean class="org.springframework.batch.retry.policy.NeverRetryPolicy"/></property>