Spring Batch Need to skip invalid xml records

excizidge

New Member
We have a business requirement to process as much of a file as we can and then move If there is an error in a file with 100 records in record 98, we want to be able to process up to that point and skip the rest of the file, moving on to the next file.We are processing the files in a MultiResourcePartitioner. \[code\]<batch:step id="processXMLstep"> <batch:tasklet transaction-manager="transactionManager"><batch:chunk reader="myXmlItemReader" processor="myProcessor Writer="myDBWriter" commit-interval="100" skip-limit="10000"><batch:skippable-exception-classes><batch:include class="java.lang.Exception"/></batch:skippable-exception-classes> </batch:chunk><batch:listeners><batch:listener ref="myFileNameListener" /> </batch:listeners></batch:tasklet><batch:end on="FAILED"/></batch:step>\[/code\]The reader is using StaxEventItemReader. I have added onProcessError(), onReadError(), onSkipInProcess(), onSkipInRead(), onSkipInWrite(), and onWriteError() methods to the listener. I can see the code hitting the OnReadError() method (and depending on the XML error, the onSkipInRead() method).Can I do something in the OnReadError() to force the job to just skip the rest of the file and move along to the next file?
 
Back
Top