Java Reference
In-Depth Information
With the job configured and built, all you need to do is deploy it on a Tomcat server. When you copy
the war file to <TOMCAT_HOME>/webapps and start up the server by executing the ./ command in
<TOMCAT_HOME>/bin , the application starts and the job is executed every 10 seconds via Quartz. How do
you know it's running? You can confirm that files are being deleted as expected and validate the output
in the <TOMCAT_HOME>/logs/catalina.out file as shown in Listing 6-18.
Listing 6-18. Job Output in catalina.out
2011-01-04 21:07:50,103 DEBUG SimpleAsyncTaskExecutor-2
[org.springframework.batch.core.job.AbstractJob] - <Job execution complete:
JobExecution: id=151, startTime=Tue Jan 04 21:07:50 CST 2011, endTime=null,
lastUpdated=Tue Jan 04 21:07:50 CST 2011, status=COMPLETED,
exitStatus=exitCode=COMPLETED;exitDescription=, job=[JobInstance: id=144,
JobParameters=[{age=9000,, path=/Users/mminella/temp}],
2011-01-04 21:07:50,105 INFO SimpleAsyncTaskExecutor-2
[] - <Job:
[FlowJob: [name=deleteFilesJob]] completed with the following parameters:
[{age=9000,, path=/Users/mminella/temp}] and the following status:
Running Spring Batch jobs in a container provides a number of advantages in an enterprise
environment including standardized packaging and deployment and more robust management options.
Another aspect of running a job in an enterprise environment is the ability to monitor and administer a
job by operations. Let's look at how you can use the Spring Batch Admin project to launch jobs.
Launching with Spring Batch Admin
Spring Batch Admin is a recent addition to how Spring Batch works. It's less an administration tool and
more an administration framework. Having gone 1.0 in early 2010, it's still evolving in its capabilities and
its role in the Spring family. However, it's a useful tool that can not only put a web interface onto the
JobRepository but also allow the execution of jobs via a web interface.
To look at Spring Batch Admin, add it to the existing deleteFiles application. Because you already
have the structure to deploy jobs via Tomcat, adding Spring Batch Admin provides a web interface for
you to view the JobRepository as well as administer jobs (start, stop, and so on). It's important to note
that you don't need to package jobs with Spring Batch Admin to be able to browse Spring Batch's
JobRepository—you only need to manage their execution.
To add Spring Batch Admin to your application, do the following:
Update your POM file to include the required jar files in your war file.
Update web.xml to include the elements required to bootstrap Spring Batch
Search WWH ::

Custom Search