Announcement Announcement Module
No announcement yet.
Sharing data b/w the steps of a job Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sharing data b/w the steps of a job


    I'm relatively new to Spring Batch, and therefore my question might seem trivial to some of you experts; but never mind, I'd like to know how can we share data b/w different steps of a JOB?

    Can we use jobRepository? if yes, how can we do that?

    Is there any other way??


  • #2
    Spring batch offers an execution context that you could use to store that kind of things. There are two flavors: the step execution context is private to the step and can be used to store local data to the step. The job execution context is global to the whole job and can be used to pass data from one step to the other.

    See also

    There's also a nice class that allows you to promote data from the step execution to the job execution based on some conditions. See ExecutionContextPromotionListener



    • #3
      Thanks for this.

      One more question -

      Can I get job to run iteratively?

      I've got a job comprising of 3 steps, namely initialUpdation, processing and notification.

      initialUpdation would update the status of a record to 'In progress'.

      Processing would pick it up and would perform some processing before updating its status.

      Notification would notify me accordingly depending upon the final status.

      Now, if I have 100 records in my table, I'd like to process those in an 'Order by Order' fashion i.e. one record should get picked up, status should turn 'In progress', processing should occur, and in the end, notification should commence.

      Can I get this done repetitively?