Class FaultTolerantChunkProcessor<I,​O>

  • All Implemented Interfaces:
    ChunkProcessor<I>, org.springframework.beans.factory.InitializingBean

    public class FaultTolerantChunkProcessor<I,​O>
    extends SimpleChunkProcessor<I,​O>
    FaultTolerant implementation of the ChunkProcessor interface, that allows for skipping or retry of items that cause exceptions during writing.
    • Method Detail

      • setKeyGenerator

        public void setKeyGenerator​(KeyGenerator keyGenerator)
        The KeyGenerator to use to identify failed items across rollback. Not used in the case of the buffering flag being true (the default).
        Parameters:
        keyGenerator - the KeyGenerator to set
      • setProcessSkipPolicy

        public void setProcessSkipPolicy​(SkipPolicy SkipPolicy)
        Parameters:
        SkipPolicy - the SkipPolicy for item processing
      • setWriteSkipPolicy

        public void setWriteSkipPolicy​(SkipPolicy SkipPolicy)
        Parameters:
        SkipPolicy - the SkipPolicy for item writing
      • setRollbackClassifier

        public void setRollbackClassifier​(org.springframework.classify.Classifier<java.lang.Throwable,​java.lang.Boolean> rollbackClassifier)
        A classifier that can distinguish between exceptions that cause rollback (return true) or not (return false).
        Parameters:
        rollbackClassifier - classifier
      • setChunkMonitor

        public void setChunkMonitor​(ChunkMonitor chunkMonitor)
        Parameters:
        chunkMonitor - monitor
      • setBuffering

        public void setBuffering​(boolean buffering)
        A flag to indicate that items have been buffered and therefore will always come back as a chunk after a rollback. Otherwise things are more complicated because after a rollback the new chunk might or might not contain items from the previous failed chunk.
        Parameters:
        buffering - true if items will be buffered
      • setProcessorTransactional

        public void setProcessorTransactional​(boolean processorTransactional)
        Flag to say that the ItemProcessor is transactional (defaults to true). If false then the processor is only called once per item per chunk, even if there are rollbacks with retries and skips.
        Parameters:
        processorTransactional - the flag value to set
      • write

        protected void write​(StepContribution contribution,
                             Chunk<I> inputs,
                             Chunk<O> outputs)
                      throws java.lang.Exception
        Description copied from class: SimpleChunkProcessor
        Simple implementation delegates to the SimpleChunkProcessor.doWrite(List) method and increments the write count in the contribution. Subclasses can handle more complicated scenarios, e.g.with fault tolerance. If output items are skipped they should be removed from the inputs as well.
        Overrides:
        write in class SimpleChunkProcessor<I,​O>
        Parameters:
        contribution - the current step contribution
        inputs - the inputs that gave rise to the outputs
        outputs - the outputs to write
        Throws:
        java.lang.Exception - if there is a problem