I am trying to implement CompletionPolicy in which I need to decide completion based on some filed for example let say my item is a order class and I need to add up order amount and once amount is more than 1000 I want chunk to complete. ordeer.amount
but in CompletionPolicy i never get item.Is there another way to achieve it? or i can get item in CompletionPolicy somehow
You can make your CompletionPolicy
implement ItemReadListener
( http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/ItemReadListener.html ). You can get access to the items through the ItemReadListener.afterRead
method.
In contrast to other standard batch components like readers, processors, writers and tasklet, a completion policy implementing a listener interface does not get registered automatically.
So you'll need to register your completion policy explicitly as a listener.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.