Spring Batch
  1. Spring Batch
  2. BATCH-1812

ItemWriteListener does not work as expected, not called when writer runs in "recoverer"

    Details

      Description

      Configuring a chunk with an ItemWriteListener I expect a call to the 'onWriteError' every time an exception is thrown from the writer. This does not seem to be the case when the writer runs in "recoverer". The consequence being that if logging is done in the 'onWriteError', only the error causing the chunk to fail will be logged, not any errors occurring when the writer handles items one by one.

      Our solution was to introduce a processor and an ItemProcessListener, where the call to the service is done in the processor and logging is put in 'onProcessError'.

      I would suggest to fix this, or make it clear in the javadoc for ItemWriteListener how it works regarding writer running in "recoverer".

      This issue is illustrated with unittests in the attached exampleproject.

        Activity

        Hide
        Sanjaya Kumar Sahoo added a comment -

        Hi ,

        I observed same. When error occurs in writer the chunk which having error is available to onWriteError. Please note that the item will be available when we implement SkipListener.

        I have observed when any error occur in Writer. The spring batch comes to onWriteError with all chunk items and then process the same chunk again one by one which becomes Item oriented processing. This is a over overhead , since we are processing same error prone record again.

        Thanks,
        SanjayaK

        Show
        Sanjaya Kumar Sahoo added a comment - Hi , I observed same. When error occurs in writer the chunk which having error is available to onWriteError. Please note that the item will be available when we implement SkipListener. I have observed when any error occur in Writer. The spring batch comes to onWriteError with all chunk items and then process the same chunk again one by one which becomes Item oriented processing. This is a over overhead , since we are processing same error prone record again. Thanks, SanjayaK
        Show
        Morten Andersen-Gott added a comment - https://github.com/SpringSource/spring-batch/pull/12

          People

          • Assignee:
            Unassigned
            Reporter:
            Per Otto Bergum Christensen
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: