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:

  1. job started
  2. executing previous steps
  3. start execution of parse-step
  4. read item
  5. process item
  6. write
    1. ooooops, exception.
    2. catch exception, log in database, go next chunk(read, process, write).
  7. continue execute other steps.
  8. finish job.

but following behavior:

  1. job started
  2. executing previous steps
  3. start execution of parse-step
  4. read item
  5. process item
  6. write
    1. ooooops, exception.
    2. process item
    3. write item
      1. ooooops, exception.
      2. catch exception, log in database, go next chunk(read, process, write).
  7. continue execute other steps.
  8. 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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -