Listing 4-19. Configuring Job Listeners in listenerJob.xml
<job id="listenerJob" incrementer="idIncrementer">
Earlier, this chapter discussed job inheritance. This inheritance has an impact on how you configure
listeners within your job. When you have a job that has listeners and it has a parent that also has
listeners, you have two options. The first option is to let the child's listeners override the parent's. If this
is what you want, then you do nothing different. However, if you want both the parent's and the child's
listeners to be executed, then when you configure the child's list of listeners, you use the merge attribute
as shown in Listing 4-20.
Listing 4-20. Merging Listeners Configured in a Parent and Child Job
<job id="listenerJob" parent="baseJob">
Listeners are a useful tool to be able to execute logic at certain points of your job. Listeners are also
available for many other pieces of the batch puzzle, such as steps, readers, writers, and so on. You see
each of those as you cover their respective components later in the topic. For now, there is just one more
piece to cover that pertains to jobs: ExecutionContext .
Batch processes are stateful by their nature. They need to know what step they're on. They need to know
how many records they have processed within that step. These and other stateful elements are vital to
not only the ongoing processing for any batch process but also restarting it if the process failed before.