The problem is probably that you're mixing pagination and update on the criteria of the reader query (IS_UPDATED).
Example with page size = 2 and 6 lines in db
- A IS_UPDATED=true
- B IS_UPDATED=true
- C IS_UPDATED=true
- D IS_UPDATED=true
- E IS_UPDATED=true
- F IS_UPDATED=true
First read page = 1 return lines A and B
After writer execution (set IS_UPDATED to false for A & B), we have in db :
- C IS_UPDATED=true
- D IS_UPDATED=true
- E IS_UPDATED=true
- F IS_UPDATED=true
Second read will move to page 2 so it will take line E & F and not C & D
Either :
- you should not update the IS_UPDATED column.
- Or you create a subclass of
RepositoryItemReader
and where you override getPage
@Override
public int getPage() {
return 0;
}
Option 2 is more resilient to batch crash / error but you have to make sure IS_UPDATED is always set to false in your writer otherwise the reader will indefinitely loop.
Option 2 will also need more tuning if you're using multithreaded step.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…