org.springframework.batch.core.step.item

## Class FaultTolerantChunkProvider<I>

- java.lang.Object
- - org.springframework.batch.core.step.item.SimpleChunkProvider<I>
  - - org.springframework.batch.core.step.item.FaultTolerantChunkProvider<I>

- All Implemented Interfaces:
    ChunkProvider<I>

      public class FaultTolerantChunkProvider<I>
      extends SimpleChunkProvider<I>

  FaultTolerant implementation of the `ChunkProcessor` interface, that allows for skipping or retry of items that cause exceptions during reading or processing.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `DEFAULT_MAX_SKIPS_ON_READ` Hard limit for number of read skips in the same chunk.

    - ### Fields inherited from class org.springframework.batch.core.step.item.SimpleChunkProvider

      `itemReader, logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `FaultTolerantChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `postProcess(StepContribution contribution, Chunk<I> chunk)`
    `protected I` | `read(StepContribution contribution, Chunk<I> chunk)` Delegates to `SimpleChunkProvider.doRead()`.
    `void` | `setMaxSkipsOnRead(int maxSkipsOnRead)`
    `void` | `setRollbackClassifier(org.springframework.classify.Classifier<java.lang.Throwable,java.lang.Boolean> rollbackClassifier)` Classifier to determine whether exceptions have been marked as no-rollback (as opposed to skippable).
    `void` | `setSkipPolicy(SkipPolicy SkipPolicy)` The policy that determines whether exceptions can be skipped on read.

    - ### Methods inherited from class org.springframework.batch.core.step.item.SimpleChunkProvider

      `doRead, getListener, provide, registerListener, setListeners`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### DEFAULT_MAX_SKIPS_ON_READ

          public static final int DEFAULT_MAX_SKIPS_ON_READ

      Hard limit for number of read skips in the same chunk. Should be sufficiently high that it is only encountered in a runaway step where all items are skipped before the chunk can complete (leading to a potential heap memory problem).
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### FaultTolerantChunkProvider

          public FaultTolerantChunkProvider(ItemReader<? extends I> itemReader,
                                            RepeatOperations repeatOperations)

  - ### Method Detail

    - #### setMaxSkipsOnRead

          public void setMaxSkipsOnRead(int maxSkipsOnRead)

      Parameters:
        `maxSkipsOnRead` - the maximum number of skips on read

    - #### setSkipPolicy

          public void setSkipPolicy(SkipPolicy SkipPolicy)

      The policy that determines whether exceptions can be skipped on read.
      Parameters:
        `SkipPolicy` -

    - #### setRollbackClassifier

          public void setRollbackClassifier(org.springframework.classify.Classifier<java.lang.Throwable,java.lang.Boolean> rollbackClassifier)

      Classifier to determine whether exceptions have been marked as no-rollback (as opposed to skippable). If encountered they are simply ignored, unless also skippable.
      Parameters:
        `rollbackClassifier` - the rollback classifier to set

    - #### read

          protected I read(StepContribution contribution,
                           Chunk<I> chunk)
                    throws java.lang.Exception

      Description copied from class: `SimpleChunkProvider`
      Delegates to `SimpleChunkProvider.doRead()`. Subclasses can add additional behaviour (e.g. exception handling).
      Overrides:
        `read` in class `SimpleChunkProvider<I>`
      Parameters:
        `contribution` - the current step execution contribution
        `chunk` - the current chunk
      Returns:
        a new item for processing
      Throws:
        `SkipOverflowException` - if specifically the chunk is accumulating too much data (e.g. skips) and it wants to force a commit.
        `java.lang.Exception` - if there is a generic issue

    - #### postProcess

          public void postProcess(StepContribution contribution,
                                  Chunk<I> chunk)

      Specified by:
        `postProcess` in interface `ChunkProvider<I>`
      Overrides:
        `postProcess` in class `SimpleChunkProvider<I>`