Announcement Announcement Module
No announcement yet.
Sharing objects across Steps Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sharing objects across Steps

    i have two setps in my job.
    step 1 creates a list of objects(can be 1000 objects in list), and step 2 needs to read from from this list as a reader. i know i can use a list reader, if i can retrieve it from step 1. i know we can use jobExecutioContext for sharing stuff across steps, but its menat for storing something not so huge.
    and we dont want to persist them to db (using jobExecutioContext will persist them to db BATCH_JOB_EXECUTION_CONTEXT table).
    i know i can use 3rd party caches like ehcache.
    just want to know if i can do this with just spring batch, without using any of the thirdparty caches.


  • #2
    If you want your job to be restartable, you will need to persist your list some place.

    If you don't need restart then why not use a simple class, e.g. ListHolder; add an instance of ListHolder as a <bean/> to your spring config; inject it as a <property/> or <constructor-arg/> into the writer from Step 1 and the reader from step2. Call listHolder.setList() from step1.writer and listHolder.getList() from step2.reader.

    Even better; if it's a simple List, just use a <util:list/>, then you don't need a holder class.


    • #3
      thanks, that worked