Announcement Announcement Module
Collapse
No announcement yet.
Spring Batch SkipListener not called when exception occurs in reader Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Batch SkipListener not called when exception occurs in reader

    This is my step configuration. My skip listeners onSkipInWrite() method is called properly. But onSkipInRead() is not getting called. I found this by deliberately throwing a null pointer exception from my reader.

    <step id="callService" next="writeUsersAndResources">
    <tasklet allow-start-if-complete="true">
    <chunk reader="Reader" writer="Writer"
    commit-interval="10" skip-limit="10">
    <skippable-exception-classes>
    <include class="java.lang.Exception" />
    </skippable-exception-classes>
    </chunk>
    <listeners>
    <listener ref="skipListener" />
    </listeners>
    </tasklet>
    </step>

    I read some forums and intercahnged the listeners tag at both levels. Inside the chunk, and outside the tasklet. Nothing is working...

    Experts please suggest

  • #2
    Firstly the listener needs to be defined inside the chunk element.
    Secondly the skip methods are not called immediately when exception is thrown, it is called immediately before transaction commit, after all chunk processing has completed.

    Comment

    Working...
    X