Class ChunkMonitor

java.lang.Object
org.springframework.batch.item.ItemStreamSupport
org.springframework.batch.core.step.item.ChunkMonitor
All Implemented Interfaces:
ItemStream

public class ChunkMonitor extends ItemStreamSupport
Manage the offset data between the last successful commit and updates made to an input chunk. Only works with single threaded steps because it has to use a ThreadLocal to manage the state and coordinate between the caller and the wrapped ItemStream.
Since:
2.0
Author:
Dave Syer, Mahmoud Ben Hassine, Seungrae Kim
  • Constructor Details

    • ChunkMonitor

      public ChunkMonitor()
  • Method Details

    • registerItemStream

      public void registerItemStream(ItemStream stream)
      Parameters:
      stream - the stream to set
    • setItemReader

      public void setItemReader(ItemReader<?> reader)
      Parameters:
      reader - the reader to set
    • incrementOffset

      public void incrementOffset()
    • getOffset

      public int getOffset()
    • resetOffset

      public void resetOffset()
    • setChunkSize

      public void setChunkSize(int chunkSize)
    • close

      public void close() throws ItemStreamException
      Description copied from interface: ItemStream
      If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.
      Throws:
      ItemStreamException
    • open

      public void open(ExecutionContext executionContext) throws ItemStreamException
      Description copied from interface: ItemStream
      Open the stream for the provided ExecutionContext.
      Parameters:
      executionContext - current step's ExecutionContext. Will be the executionContext from the last run of the step on a restart.
      Throws:
      ItemStreamException
    • update

      public void update(ExecutionContext executionContext) throws ItemStreamException
      Description copied from interface: ItemStream
      Indicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.
      Parameters:
      executionContext - to be updated
      Throws:
      ItemStreamException