org.springframework.batch.core

## Interface ChunkListener

- All Superinterfaces:
    StepListener
  All Known Implementing Classes:
    ChunkListenerAdapter, ChunkListenerSupport, CompositeChunkListener, MulticasterBatchListener, PartitionCollectorAdapter, StagingItemListener, StepListenerSupport

      public interface ChunkListener
      extends StepListener

  Listener interface for the lifecycle of a chunk. A chunk can be through of as a collection of items that will be committed together.
  Author:
    Lucas Ward, Michael Minella

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static java.lang.String` | `ROLLBACK_EXCEPTION_KEY`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterChunk(ChunkContext context)` Callback after the chunk is executed, outside the transaction.
    `void` | `afterChunkError(ChunkContext context)` Callback after a chunk has been marked for rollback.
    `void` | `beforeChunk(ChunkContext context)` Callback before the chunk is executed, but inside the transaction.

- - ### Field Detail

    - #### ROLLBACK_EXCEPTION_KEY

          static final java.lang.String ROLLBACK_EXCEPTION_KEY

      See Also:
        Constant Field Values

  - ### Method Detail

    - #### beforeChunk

          void beforeChunk(ChunkContext context)

      Callback before the chunk is executed, but inside the transaction.
      Parameters:
        `context` - The current `ChunkContext`

    - #### afterChunk

          void afterChunk(ChunkContext context)

      Callback after the chunk is executed, outside the transaction.
      Parameters:
        `context` - The current `ChunkContext`

    - #### afterChunkError

          void afterChunkError(ChunkContext context)

      Callback after a chunk has been marked for rollback. It is invoked after transaction rollback. While the rollback will have occurred, transactional resources might still be active and accessible. Due to this, data access code within this callback will still "participate" in the original transaction unless it declares that it run in its own transaction. Hence: Use PROPAGATION_REQUIRES_NEW for any transactional operation that is called from here.
      Parameters:
        `context` - the chunk context containing the exception that caused the underlying rollback.