org.springframework.batch.core

## Interface ItemWriteListener<S>

- All Superinterfaces:
    StepListener
  All Known Implementing Classes:
    CompositeItemWriteListener, DefaultItemFailureHandler, ItemListenerSupport, ItemWriteListenerAdapter, MulticasterBatchListener, StagingItemListener, StepListenerSupport

      public interface ItemWriteListener<S>
      extends StepListener

  Listener interface for the writing of items. Implementations of this interface will be notified before, after, and in case of any exception thrown while writing a list of items.
  Author:
    Lucas Ward

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterWrite(java.util.List<? extends S> items)` Called after `ItemWriter.write(java.util.List)` This will be called before any transaction is committed, and before `ChunkListener.afterChunk(ChunkContext)`
    `void` | `beforeWrite(java.util.List<? extends S> items)` Called before `ItemWriter.write(java.util.List)`
    `void` | `onWriteError(java.lang.Exception exception, java.util.List<? extends S> items)` Called if an error occurs while trying to write.

- - ### Method Detail

    - #### beforeWrite

          void beforeWrite(java.util.List<? extends S> items)

      Called before `ItemWriter.write(java.util.List)`
      Parameters:
        `items` - to be written

    - #### afterWrite

          void afterWrite(java.util.List<? extends S> items)

      Called after `ItemWriter.write(java.util.List)` This will be called before any transaction is committed, and before `ChunkListener.afterChunk(ChunkContext)`
      Parameters:
        `items` - written items

    - #### onWriteError

          void onWriteError(java.lang.Exception exception,
                            java.util.List<? extends S> items)

      Called if an error occurs while trying to write. Will be called inside a transaction, but the transaction will normally be rolled back. There is no way to identify from this callback which of the items (if any) caused the error.
      Parameters:
        `exception` - thrown from `ItemWriter`
        `items` - attempted to be written.