Results 1 to 2 of 2

Thread: Spring Batch SkipListener not called when exception occurs in reader

  1. #1

    Default 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. #2
    Join Date
    May 2011
    Location
    New Delhi, India
    Posts
    157

    Default

    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •