Interface SkipListener in 1.0.0-FINAL looks really interesting.
My need is to persist the skipped items in a database (in order to determine easily which items where skipped and what action I should do).
The first question I have to answer is how to get the skipped item.
I'll get it from SkipListener#onSkipInWrite(Object,Throwable) method if there was an error during writing process.
But if the error occurs in the read process, I'll be screwed !
Since I'm going to use ValidatingItemReader, I'm expecting that most skip errors will be during the read process (item validation error).
I've quickly implemented a solution base on aspects. An ItemContextInterceptor is applied on every ItemRead#read and every FieldSetMapper#mapLine
This aspect just add the returned element to a ThreadLocal ItemContext.
Then, whenever SkipListener is called, I've got every read item in the chain and can persist them to the database.
Is it a good solution ? Personnally I'm not too fond on relying on aspects for this (a bit intrusive). Perhaps I've missed something in the framework.
If yes, can we imagine being part in the future of Spring Batch (if there's a common need of course ) ?
Thanks for the feedback