Announcement Announcement Module
No announcement yet.
onSkipInRead being called multiple times Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • onSkipInRead being called multiple times

    I have both ItemReader and ItemWriter that are expected to throw Exceptions, and I have a SkipListener configured as well. However, the onSkipInRead is being called multiple times on the same item.

    The javadoc seems to mention this:

    	 * Callback for a failure on read that is legal, so is not going to be
    	 * re-thrown. In case transaction is rolled back and items are re-read, this
    	 * callback will occur repeatedly for the same cause.  This will only happen
    	 * if read items are not buffered.
    	 * @param t cause of the failure
    	void onSkipInRead(Throwable t);
    as well as in the reference:

    5.1.7. Controlling Rollback
    By default, regardless of retry or skip, any exceptions thrown from the ItemWriter will cause the transaction controlled by the Step to rollback. If skip is configured as described above, exceptions thrown from the ItemReader will not cause a rollback. However, there are many scenarios in which exceptions thrown from the ItemWriter should not cause a rollback because no action has taken place to invalidate the transaction. For this reason, the Step can be configured with a list of exceptions that should not cause rollback.
    I tried adding the code below to my step config, but it remains the same:
          <batch:include class="java.lang.Exception" />
    ChunkOrientedTasklet calls
    chunkProvider.postProcess(contribution, inputs);
    multiple times on the same error.

    What should I do to make sure onSkipInRead is called only once given that ItemWriter throws Exception?

    Related threads: