Spring Batch pause and then continue -
i'm writing job read excel file, x number of rows , i'd pause hour before continues next x number of rows. how do this?
i have job.xml file contains following. subscriptiondiscoverer fetches file , pass on processor. subscriptionwriter should write file when processor done.
<job id="subscriptionjob" xmlns="http://www.springframework.org/schema/batch" incrementer="jobparamsincrementer"> <validator ref="jobparamsvalidator"/> <step id="readfile"> <tasklet> <chunk reader="subscriptiondiscoverer" processor="subscriptionprocessor" writer="subscriptionwriter" commit-interval="1" /> </tasklet> </step> </job> is there kind of timer use or kind of flow structure? it's large file of 160000 rows should processed.
i hope has solution share. thank you!
i'm thinking of 2 possible approaches start with:
- stop job, , restart again (after hour) @ last position. can start taking on how change batchstatus notify intent stop job. see http://docs.spring.io/spring-batch/2.0.x/cases/pause.html or @ how spring batch admin implements way of communicating pause flag (http://docs.spring.io/spring-batch-admin/reference/reference.xhtml). may need implement persistence store position (row number) job know start processing again. can use scheduler restart job.
-or-
- add chunklistener , implement following in afterchunk(chunkcontext context): check if x number of rows has been read far, , if yes, implement pause mechanism (e.g., simple thread.sleep or more consistent way of pausing step). check number of rows read, may use stepexecution.getreadcount() chunkcontext.getstepcontext().stepexecution().
do note afterchunk called outside transaction indicated in javadoc:
callback after chunk executed, outside transaction.
Comments
Post a Comment