This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

Getting hold of the Line Number in SkipListener

May 14th, 2010, 12:41 PM

Hi,
I am currently doing some validations in the ItemProcessor and i try to skip the record when the validation fails. At the same time i also have configured a SkipListener which needs to log this record to the tables so that it can be tracked and fixed later. One of the req is to know the line number so that it would be easy to trace the record the file. Hence i want to log the line number of this record as well. Is there a way to get hold of the line number in the onSkipInProcess() method of SkipListener. Initially i thought i would use the readCount of StepExecution, but i presume it will not yield proper results if the job restarts.

Could somebody let me know the way to get hold of the line number in the onSkipInProcess() method for a ValidationException?

I think it's not so easy. As you you see your requirement is related mostly to flat file processing but other ItemReaders can not honor order of items (eg. database readers of unsorted data). So I suggest to identify item by some unique id instead of depends on line (which no make seans in general approach to ItemReaders).
I know that maybe not so easy if you are not an owner of type spec
HTH