Oct 3rd, 2011, 02:32 PM
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">
<chunk reader="Reader" writer="Writer"
<include class="java.lang.Exception" />
<listener ref="skipListener" />
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
Oct 3rd, 2011, 11:03 PM
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