This is more to share what our team has encountered in our testing using Spring Batch 'StepListeners' (2.0.1.RELEASE).
If you happen to configure your step listeners the way as shown in the doc i.e. explicitly configured as part of the <step> and <tasklet>
and then your listeners are implemented in the same class as the ItemReader, ItemProcessor or ItemWriter then you'll encounter duplicate invocations of the StepListener methods.
<chunk reader="reader" writer="writer" commit-interval="10"/>
At first we thought there's something wrong in our implementation, context loading, job invocation, logging, etc until we suspected that probably the listeners were being registered twice and that's probably causing the duplicate runs. True enough, if your StepListeners are in the same class as the ItemReader, ItemProcessor or ItemWriter they are automatically registered! So explicitly configuring it again in the <step> config make them to be registered twice and thus invoked twice.
Well it is documented here and we missed it. http://static.springsource.org/sprin...gStepExecution
How did this happen? Initially our StepListener implementations are in a separate class so the above configuration worked. Later we decided to merge it with the Item listener implementations and changing only the class/bean in the <listener> configuration. Who would have thought we are now registering the step listeners twice?
Spring Batch should probably be more intelligent to detect duplicate listeners being registered twice. It's good that it can register StepListeners automatically but might as well not do it if it cannot detect manual registration that will cause duplicates.