History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BATCH-419
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Minor Minor
Assignee: Robert Kasanicky
Reporter: Marten Deinum
Votes: 2
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
Spring Batch

JobListener and StepListener should pass in JobExecution/StepExecution in each method

Created: 05/Mar/08 01:59 PM   Updated: 06/Mar/08 10:22 AM
Component/s: Core
Affects Version/s: 1.0.0.m5
Fix Version/s: 1.0.0.rc1

Time Tracking:
Original Estimate: 0.06d
Original Estimate - 0.06d
Remaining Estimate: 0.06d
Remaining Estimate - 0.06d
Time Spent: Not Specified
Remaining Estimate - 0.06d


 Description  « Hide
I was trying to implement some logging after that a step finished, but in the afterStep method I don't have the StepExecution available to print those things. It would be great if all the methods in the listener had the StepExecution passed in. The same could be said for the JobListener....

 All   Comments   Work Log   Change History   FishEye   Related Builds      Sort Order: Ascending order - Click to sort in descending order
Marten Deinum - 05/Mar/08 02:02 PM
I can think of 2 workarounds for this issue but still they are workarounds. one would be to make the listener stateful (i.e. register the step in the beforeStep and read properties from it in the afterStep) but that is ugly imho. A bit cleaner would be to instead of keeping a reference to the StepExecution put it in a ThreadLocal and retrieve it from there. But stll also that feels like a smell.

Gregory Kick - 05/Mar/08 02:58 PM
I would appreciate the same symmetry on the ItemWriteListener (i.e. afterWrite(Object item)) as well. +1 from me.

Dave Syer - 06/Mar/08 02:29 AM
I will make the changes as requested but here are two comments:

1) stateful is pretty normal in batch jobs. We strongly recommend a new ApplicationContext per JobExecution

2) I am still slightly uneasy about passing the StepExecution and JobExecution into user APIs. They are mutable, and changes (even inadvertent ones) could cause side effects.

Robert Kasanicky - 06/Mar/08 08:38 AM
arguments added to both afterStep and afterJob listener methods

Dave Syer - 06/Mar/08 09:27 AM
You missed out the onError methods though?

Robert Kasanicky - 06/Mar/08 09:34 AM
assumed issue did not apply to the onError method - will fix that soon.

Robert Kasanicky - 06/Mar/08 10:22 AM
added StepExecution argument to the onErrorInStep as well