Announcement Announcement Module
No announcement yet.
Fresh Application Context for each job Execution Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fresh Application Context for each job Execution

    Going through a section on Job Configuration in spring batch (

    I saw that it recommends creating a new Application Context for each job Execution.

    4.1.4. JobFactory and Stateful Components in Steps

    Unlike many traditional Spring applications, many of the components of a batch application are stateful; the file readers and writers are obvious examples. The recommended way to deal with this is to create a fresh ApplicationContext for each job execution.

    I think i'm missing the idea behind this. Why would you need to refresh the context at each job start and close it at job end?

    If its about closing Streams/destroying resources etc.- doesn't the ItemStream interface callback's close() etc. provide that already?

    Could someone enlighten...


  • #2
    Ignore that (it's a remnant from 1.1.x). Just use scope="step" in your stateful components. I thought the user guide had been updated but that must have been in a different chapter.