I am not sure if the FlatFileItemReader has the capability to store the last line when an exception is being met. So that when i re-run the batch application it will be able to continue from the last line.
Any example to implement the following use cause would be helpful Thanks!
public static FlatFileItemReader<Employee> reader(String path){
FlatFileItemReader<Employee> reader = new FlatFileItemReader<Employee>();
reader.setResource(new ClassPathResource(path));
reader.setLineMapper(new DefaultLineMapper<Employee>() {
{
setLineTokenizer(new DelimitedLineTokenizer() {
{
setNames(new String[] {"firstName", "lastName", "emailId"});
}
});
setFieldSetMapper(new BeanWrapperFieldSetMapper<Employee>() {
{
setTargetType(Employee.class);
}
});
}
});
return reader;
}}
I think It's a capability of the
FlatFileItemReader
It means that if you set chunk size to 1 in your job and reader fails on line 195, next time the job pick chunk no 195 and continue it from line no.195. Also at application start spring checks failed executions and restarts it automatically. Some docs:
Retry
Restartibility