Listing 6-7. Output from JobRegistryBackgroundJobRunner
2011-04-30 01:36:24,105 DEBUG main
ContextFactory$ResourceXmlApplicationContext] - <Unable to locate
LifecycleProcessor with name 'lifecycleProcessor': using default
2011-04-30 01:36:24,106 DEBUG main
<Registering job: helloWorldJob from context:
Started application. Interrupt (CTRL-C) or call
JobRegistryBackgroundJobRunner.stop() to exit.
JobRegistryBackgroundJobRunner is a useful tool for bootstrapping Spring and your jobs from a
command line without executing them immediately. This is a much more typical scenario found in
production-like environments. However, most production environments don't fire up a Java process
and let it run and kick off jobs by hand. Instead, jobs are scheduled. They may be run in a servlet
container for consistency of deployment, and they may need to be managed by the Spring Admin
project. The next section covers how to do all that.
Spring Batch is an excellent tool to develop batch processes, but it's rarely administered on its own.
Enterprises need the ability for batch jobs to be administered by operations teams. They need to be able
to deploy jobs in a consistent way for the enterprise. They need to be able to start, stop, and schedule
jobs in a way that doesn't require programming (typically through an enterprise scheduler of some
kind). This section looks at how to schedule batch jobs with the open source scheduler Quartz, how to
deploy Spring Batch jobs in the Tomcat servlet container, and finally how to start jobs with the
administration tool Spring Batch Admin.
Scheduling with Quartz
Many enterprise schedulers are available. They range from the crude but very effective crontab to
enterprise automation platforms that can run into the millions of dollars. The scheduler you use here is
an open source scheduler called Quartz ( www.quartz-scheduler.org/ ). Th is scheduler is commonly used
in Java environments of all sizes. In addition to its power and solid community support, it has an
established history of Spring integration that is helpful in executing jobs.
Given the scope of Quartz, this topic won't cover all of it here. However, a brief introduction to how
it works and how it integrates with Spring is warranted. Figure 6-1 shows the components of Quartz and