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>
FaultTolerant implementation of the
ChunkProvider interface, that allows for
skipping or retry of items that cause exceptions during reading or processing.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intHard 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
ConstructorsConstructorDescriptionFaultTolerantChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations) -
Method Summary
Modifier and TypeMethodDescriptionvoidpostProcess(StepContribution contribution, Chunk<I> chunk) protected Iread(StepContribution contribution, Chunk<I> chunk) Delegates toSimpleChunkProvider.doRead().voidsetMaxSkipsOnRead(int maxSkipsOnRead) voidsetRollbackClassifier(org.springframework.classify.Classifier<Throwable, Boolean> rollbackClassifier) Classifier to determine whether exceptions have been marked as no-rollback (as opposed to skippable).voidsetSkipPolicy(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, setMeterRegistry
-
Field Details
-
DEFAULT_MAX_SKIPS_ON_READ
public static final int DEFAULT_MAX_SKIPS_ON_READHard 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:
-
-
Constructor Details
-
FaultTolerantChunkProvider
public FaultTolerantChunkProvider(ItemReader<? extends I> itemReader, RepeatOperations repeatOperations)
-
-
Method Details
-
setMaxSkipsOnRead
public void setMaxSkipsOnRead(int maxSkipsOnRead) - Parameters:
maxSkipsOnRead- the maximum number of skips on read
-
setSkipPolicy
The policy that determines whether exceptions can be skipped on read.- Parameters:
skipPolicy- instance ofSkipPolicyto be used by FaultTolerantChunkProvider.
-
setRollbackClassifier
public void setRollbackClassifier(org.springframework.classify.Classifier<Throwable, 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
Description copied from class:SimpleChunkProviderDelegates toSimpleChunkProvider.doRead(). Subclasses can add additional behaviour (e.g. exception handling).- Overrides:
readin classSimpleChunkProvider<I>- Parameters:
contribution- the current step execution contributionchunk- the current chunk- Returns:
- a new item for processing or
nullif the data source is exhausted - Throws:
SkipOverflowException- if specifically the chunk is accumulating too much data (e.g. skips) and it wants to force a commit.Exception- if there is a generic issue
-
postProcess
- Specified by:
postProcessin interfaceChunkProvider<I>- Overrides:
postProcessin classSimpleChunkProvider<I>
-