You are right. In fact, i writed this code yesterday nigth without be with my computer of developpement but i have really this problem.
Below a complete code with my problem :
Code:
public class MyItemWriter implements ItemWriter<Integer>, ItemStream {
private Integer mnt = 0;
public void write (List<? extends Integer> items) {
// My business with the possibity to be an exception
// .....
// An example with the using of a field of my class
for (Integer oneMnt : items) {
mnt += oneMnt;
}
}
public void open(ExecutionContext arg0) throws ItemStreamException {
mnt = 0;
}
public void close() throws ItemStreamException {}
public void update(ExecutionContext arg0) throws ItemStreamException {}
}
In this example, with a commitInterval to 5 and only 5 items to read, if the item n°4 throw an exception skippable, the mnt after step is bad. Is equals to :
mnt = (n°1) + (n°2) + (n°3) + (n°1 + n°2 + n°3 + n°5)
How connect my field to the transaction manager like you say ?