img
Importing/exporting information from/to external systems
·
End-of-day processing for transaction processing systems
·
Generating external document (for example, monthly customer statements)
·
Although every batch job executes different logic, the high-level flow is similar. The following is the
flow of a typical batch job:
Reading: To read information from a source. The source can be a file, database,
1.
JMS message, web service request, and so on.
Processing: To process the information read from the source. This consists of
2.
validating, deriving other supporting information, applying business rules, and
so on.
Writing: To output the processed information into the destination. The
3.
destination can be a file, database, JMS message, web service response, and so on.
Spring Batch provides the execution infrastructure and many out-of-the-box classes that greatly
simplify the work of developing a batch job. In this chapter, we will see how to use Spring Batch to
implement a batch job that performs the batch import of contact information in XML format from
a file.
There are two main generations of the Spring Batch project, namely, version 1 and version 2.
Version 2 differs from version 1 greatly, and the most important change is from item-oriented processing
to chunk-oriented processing. In version 1's item-oriented processing, each record (for example, a line
within a flat file) will go through the entire read -> processing -> write flow. This proved to have poor
performance when processing a large amount of information.
In version 2, Spring Batch introduced chunk-oriented processing. In this processing, the read ->
processing steps are repeated several times as defined by the chunk size. Every time the chunk size is
reached, Spring Batch sends the entire batch of processed information to the write step to perform a
bulk update. This greatly improves the performance when processing a large amount of data.
Spring Batch Infrastructure Components
Table 20-1 lists the main runtime infrastructure components of Spring Batch. Note that all components
are interfaces.
Table 20-1. Spring Batch Infrastructure Components
Component
Description
JobRepository
Provides data access operations (CRUD) to the underlying Spring
Batch metadata.
JobLauncher
For launching a job. Responsible for starting a job execution based
on a given job and parameters.
JobOperator (new in version 2)
Provides batch job operations (for example, stop a running job,
restart a failed or stopped job).
JobExplorer (new in version 2)
Retrieves the job execution status information from metadata.
Search WWH :
Custom Search
Previous Page
Spring Framework 3 Topic Index
Next Page
Spring Framework 3 Bookmarks
Home