I have following step in batch job.
<batch:step id="parse-step">
<batch:tasklet>
<batch:chunk reader="xmlCommonReader"
processor="xmlCommonProcessor"
writer="xmlCommonWriter"
commit-interval="1">
<batch:skip-policy>
<bean class="org.springframework.batch.core.step.skip.AlwaysSkipItemSkipPolicy" scope="step"/>
</batch:skip-policy>
<batch:retry-policy>
<bean class="org.springframework.retry.policy.NeverRetryPolicy" scope="step"/>
</batch:retry-policy>
</batch:chunk>
</batch:tasklet>
<batch:next on="FAILED" to="file-failed-step"/>
<batch:next on="COMPLETED" to="file-success-step"/>
<batch:listeners>
<batch:listener ref="parseStepExecutionListener"/>
<batch:listener ref="parseStepSkipListener"/>
</batch:listeners>
</batch:step>
When some exception throws, i catch him in parseStepSkipListener and log in database.
I expect the following behavior:
- Job Started
- Executing previous steps
- Start execution of parse-step
- Read item
- Process item
- Write
- Ooooops, exception.
- Catch exception, log in database, go to next chunk(Read, Process, Write).
- Continue execute other steps.
- Finish job.
But actually i get following behavior:
- Job Started
- Executing previous steps
- Start execution of parse-step
- Read item
- Process item
- Write
- Ooooops, exception.
- Process item
- Write item
- Ooooops, exception.
- Catch exception, log in database, go to next chunk(Read, Process, Write).
- Continue execute other steps.
- Finish job.
So, one chunk of data try to process and write two times.