Spring Batch comes with listeners. They intercept the job execution to perform certain tasks. StepListener
is a super
class for the following mentioned listeners:
SkipListener
: One of the most common use cases forSkipListener
is to log out a skipped item so that another batch process, or even human process, can be used to evaluate and fix the issue leading to the skip. Because there are many cases in which the original transaction may be rolled back, Spring Batch makes two guarantees:The appropriate
skip
method (depending on when the error happened) will only be called once per item.The
SkipListener
will always be called just before the transaction is committed. This is to ensure that any transactional resources called by the listener are not rolled back by a failure withinItemWriter
.
ChunkListener
: These listeners can be configured with a step, and if the step is of the type chunk-styled step, this will have bothItemReader
andItemWriter...