Announcement Announcement Module
Collapse
No announcement yet.
ExecutionContext handle in ItemProcessor<T> Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • ExecutionContext handle in ItemProcessor<T>

    How do we get the handle of ExecutionContext (Job or Step) inside the ItemProcessor?

    I don't want it to implement this in StepListener, which has the handle to ExecutionContext.

    Could anyone help?

  • #2
    You can leverage the @BeforeStep listener annotation to grab the StepExecution before the step is started. From there you can get whatever you're after from StepExecution.

    See the ItemWriter example in the reference docs.
    http://static.springsource.org/sprin...aToFutureSteps

    Comment


    • #3
      Thanks jglynn.

      My bad. I entirely missed that chapter. I focused on Configuring a Step chapter.

      Thanks Again.

      Comment


      • #4
        ExecutionContext

        Is ExecutionContext thread safe? If i configure my batch as to run in multi-thread, does it gives me any problem when using values from ExecutionContext? I am planning to set a Map in the context.

        Comment


        • #5
          ExecutionContext is just backed by a Map and has no intrinsic guarantees about thread safety, i.e. it's up to clients of the context to synchronize access to it if necessary. However, I would say it is likely to be a bad move to use the context outside the ItemStream and StepExecutionListener interfaces, and access in those places will (I think) be synchronized by the framework.

          Comment

          Working...
          X