Spring Batch retry-policy, and skip-policy issue -
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 exception throws, catch him in parsestepskiplistener , log in database.
i expect 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 next chunk(read, process, write).
- continue execute other steps.
- finish job.
but 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 next chunk(read, process, write).
- continue execute other steps.
- finish job.
so, 1 chunk of data try process , write two times.
in few words:
this happens because when error occured in write step sb doesn't know object caused exception rollback performed , every single item of last uncommited chunk processed/writed again mini-chunk detect object cause of main write error. can read more (with diagrams) here
Comments
Post a Comment