spring batch - How to read multiple items in ItemReader -


following use case spring batch.

  1. reads input web service. web service return records.

  2. process records.

  3. write processed records 1 one.

i'm clear step 2 , 3 not able figure out how implement reader can read records in 1 go. how pass records 1 one item processor /writer? should using tasklet instead of reader/writer?

what webservice returns? collection of object guess!

your itemreader need loop on collection , remove items one-by-one return null when processed.

what @kik saying rest handled spring batch based on commit-interval. if have commit0interval of 10 example, reader read 10 items, passed 10 items itemproc. pass them again after writer.

hope clarify

edit: 1) in spring batch have more 1 option need.

easy option, create custom mywsitemreader implements itemreader interface.

-define method init() in class call webservice , put results in collection attribute of mywsitemreader.

-implements method read() interface. (read carfully contact in doc - must return null when passed elements of collection)

-then, configure steplistener around step , implement beforestep() method call init() of mywsitemreader. can autowire reader in listener accomplish this.

alternatively, mywsitemreader implements initializingbean. have implement afterpropertyset() call ws , store result in private attribute of mywsitemreader

regards


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -