public class FaultTolerantChunkProvider<I> extends SimpleChunkProvider<I>
ChunkProcessor interface, that
allows for skipping or retry of items that cause exceptions during reading or
processing.| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_MAX_SKIPS_ON_READ
Hard limit for number of read skips in the same chunk.
|
itemReader, logger| Constructor and Description |
|---|
FaultTolerantChunkProvider(org.springframework.batch.item.ItemReader<? extends I> itemReader,
org.springframework.batch.repeat.RepeatOperations repeatOperations) |
| 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.
|
doRead, getListener, provide, registerListener, setListenerspublic static final int DEFAULT_MAX_SKIPS_ON_READ
public FaultTolerantChunkProvider(org.springframework.batch.item.ItemReader<? extends I> itemReader, org.springframework.batch.repeat.RepeatOperations repeatOperations)
public void setMaxSkipsOnRead(int maxSkipsOnRead)
maxSkipsOnRead - the maximum number of skips on readpublic void setSkipPolicy(SkipPolicy skipPolicy)
skipPolicy - instance of SkipPolicy to be used by FaultTolerantChunkProvider.public void setRollbackClassifier(org.springframework.classify.Classifier<java.lang.Throwable,java.lang.Boolean> rollbackClassifier)
rollbackClassifier - the rollback classifier to setprotected I read(StepContribution contribution, Chunk<I> chunk) throws java.lang.Exception
SimpleChunkProviderSimpleChunkProvider.doRead(). Subclasses can add additional behaviour
(e.g. exception handling).read in class SimpleChunkProvider<I>contribution - the current step execution contributionchunk - the current chunknull if the data source is exhaustedSkipOverflowException - 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 issuepublic void postProcess(StepContribution contribution, Chunk<I> chunk)
postProcess in interface ChunkProvider<I>postProcess in class SimpleChunkProvider<I>