Announcement Announcement Module
Collapse
No announcement yet.
Question on listener callback ordering during retry processing Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Question on listener callback ordering during retry processing

    Hi All,

    Is it correct to assume that beforeChunk and afterChunk will always be called during retry processing?

    Also, just want to confirm that if an exception is raised during write, than whole chunk is rolled back and reprocessed (based on SkipPolicy) and skipped item is not passed into writer again. Will commit happen here for individual item or for the whole chunk? That is what is a transactional boundary during retry?

    I wanted to see ordering of the listeners so I just threw an exception in my Writer impl. During retry I see before/afterChunk called for each item. Log file attached.

    I was surprised to see before/after chunk called with retry.

    Code:
    12:04:28.418 [main]            INFO  .....Listener - Job with id '3' - beforeChunk, counter is at 10 
    12:04:28.418 [main]            INFO  .....Listener - Job with id '3' beforeProcess item '1' 
    12:04:28.419 [main]            INFO  .....Listener - Job with id '3' afterProcess item '1' 
    12:04:28.436 [main]            INFO  .....Listener - Job with id '3' afterWrite for item(s) '[1]' 
    12:04:28.440 [main]            INFO  .....Listener - Job with id '3' - afterChunk, counter is at 10 
    12:04:28.446 [main]            INFO  .....Listener - Job with id '3' - beforeChunk, counter is at 10 
    12:04:28.446 [main]            INFO  .....Listener - Job with id '3' beforeProcess item '2' 
    12:04:28.447 [main]            INFO  .....Listener - Job with id '3' afterProcess item '2' 
    12:04:28.458 [main]            INFO  .....Listener - Job with id '3' afterWrite for item(s) '[2]' 
    12:04:28.461 [main]            INFO  .....Listener - Job with id '3' - afterChunk, counter is at 10 
    12:04:28.462 [main]            INFO  .....Listener - Job with id '3' - beforeChunk, counter is at 10

  • #2
    The result you see is expected, but not for the reason you suggest. If your writer throws an exception on every call the Tasklet will attempt to scan for the failed item by re-trying the chunk one item at a time (in a separate transaction). If all items fail, then that transaction rolls back and the item is sent to the skip / recovery step in a new transaction. ChunkListener.beforeChunk is called before every attempt, and ChunkListener.afterChunk is called only after a successful transaction (which in your case is all the skips).

    Comment

    Working...
    X