Java Reference
In-Depth Information
components that make up the batch domain. Finally, the infrastructure layer includes item readers and
writers as well as the required classes and interfaces to address things like restartability.
This section goes deeper into the architecture of Spring Batch and defines some of the concepts
referred to in the last chapter. You then learn about some of the scalability options that are key to batch
processing and what makes Spring Batch so powerful. Finally, the chapter discusses outline
administration options as well as where to find answers to your questions about Spring Batch in the
documentation. You start with at the architecture of batch processes, looking at the components of the
core layer.
Examining Jobs and Steps
Figure 2-1 shows the essence of a job. Configured via XML, a batch job is a collection of steps in a
specific order to be executed as part of a predefined process. Let's take for example the nightly
processing of a user's bank account. Step 1 could be to load in a file of transactions received from
another system. Step 2 would all credits to the account. Finally, step 3 would apply all debits to the
account. The job represents the overall process of applying transactions to the user's account.
Figure 2-1. A batch job
When you look deeper, at an individual step, you see a self-contained unit of work that is the main
building block of a job. Each step has up to three parts: an ItemReader, an ItemProcessor, and an
ItemWriter. Notice that the names for each of these elements (ItemReader, ItemProcessor, and
ItemWriter) are singular. That's by intent. Each of these pieces of code is executed on each record to be
processed. A reader reads in a single record and passes it to the item processor for processing before it's
sent to the item writer to be persisted in some way.
I stated a step has up to three parts. A step isn't required to have an ItemProcessor. .It's ok to have a
step that consists of just an ItemReader and an ItemWriter (common in data-migration jobs) or just a
tasklet (the equivalent of an ItemProcessor when you don't have any data to read or write). Table 2-1
walks through the interfaces that Spring Batch provides to represent these concepts.
Table 2-1. The Interfaces that Make Up a Batch Job
The object representing the job, as
configured in the job's XML file. Also
provides the ability to execute the job.
Search WWH ::

Custom Search