user14054021
user14054021

Reputation: 35

Spring Batch skip all and get that exceptions in StepListener

I want skip all exceptions (using AlwaysSkipPolicy) and then handle all skipped exceptions with errors in StepListener. I want create summary message at the end of step with written/read items and when any exception occured then about how many and with what exception that items was skipped. When I using skip policy always true + step listener, I have 0 exceptions in "failureExceptions". When I turned off skip policy i got exception there but then when exception occured, job stoping.

Upvotes: 1

Views: 1066

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31590

SkipListener is what you are looking for. It allows you to intercept skipped items during all phases of a chunk-oriented step (ie read, process and write). This listener gives you access to the skipped item and the exception that caused it to be skipped, so you should be able to implement the reporting you need with this listener.

Upvotes: 2

Related Questions