Aug 28th, 2012, 11:38 AM
Exception handling in Spring batch job
I am trying to implement a listener (extending org.springframework.batch.core.listener.ItemListen erSupport<I,O>)) and overriding the onReadError, onWriteError, onProcessError methods to log the error messages (along with the item which caused the exception). This works fine and I see the log messages in console.
Now I need to log these err'd out items in a new flat file (in the same format of the flat file that is read by my step readers). I am having difficulty implementing this through the spring batch framework. I have tried to inject a FlatFileWriter in my listener class - but this file is always empty - even though i see that the error items are logged.
Is there a way to achieve this ? I need a listener class that is used in all my steps and which will log the error items in a separate flat file..
Tags for this Thread