0
votes

I have a spring batch job where in I use FlatFileItemReader and populate it to Pojo objects (items). My file has a footer line that gives me the number of records in the file. I need to validate that my List has that many objects.

I cannot do it through ItemProcessor as it gives me only one item at a time. Is there any other way to do such a validation in spring batch?

Thanks Paddy

1
can you describe what you mean by "i need to validate that my List has that many objects"Michael Pralow
Yes, if my flat file has 80 records excluding header and tail. My trail record will give me the count 80 for the field recordCount. Each record is identified as Header , trail or data record by key H, T and R respectively in a field recordType. I need a way to get the whole list of records in a method, iterate through it and see if the count of records with recordType as R is 80.Paddy Mahadeva
Is there any issue in using Item Reader listener and Job Execution context?Karthik Prasad

1 Answers

0
votes

Spring's FlatFileItemReader provides a feature to skip the number of line at the top and end. This issue got solved using them. Don't have a postable code, but was led to the answer from the the reader writer documentation.

https://docs.spring.io/spring-batch/trunk/reference/html/readersAndWriters.html