Reputation: 119
I want to keep track of records which was failed during the reading step of a job. I have used SkipListener for this.
public class SkipListener implements org.springframework.batch.core.SkipListener {
public void onSkipInProcess(Object arg0, Throwable arg1) {
}
public void onSkipInRead(Throwable arg0) {
System.out.println(arg0);
}
public void onSkipInWrite(Object arg0, Throwable arg1) {
}
}
I want to store the line skipped by reader in another csv file.
From the above onSkipInRead(Throwable arg0)
method i am getting throwable object like this :
org.springframework.batch.item.file.FlatFileParseException: Parsing error at line: 5 in resource=[class path resource [files/input2.csv]], input=[1005,anee,Active,500000,34,888]
I want only record as : 1005,anee,Active,500000,34,888
How can I get this or I have to parse manually the throwable object and get this?
Second Question is that : I want to keep track of Number of items actually submitted to job, Number of item skipped, Number of item processed successfully, Is there any support provided by Spring Batch for this?
Upvotes: 2
Views: 2887
Reputation: 1964
For your first question, you have to parse manually the exception message, since the item couldn't be read.
For your second question, SpringBatch provides methods on the StepExecution objects :
stepExecution.getReadCount()
stepExecution.getReadSkipCount()
stepExecution.getProcessCount()
stepExecution.getProcessSkipCount()
stepExecution.getWriteCount()
stepExecution.getWriteSkipCount()
Upvotes: 1