C H A P T E R 3
This topic is designed to not only explain how the many features of Spring Batch work but also
demonstrate them in detail. Each chapter includes a number of examples that show how each feature
works. However, examples designed to communicate individual concepts and techniques may not be
the best for demonstrating how those techniques work together in a real-world example. So, in Chapter
10 you create a sample application that is intended to emulate a real-world scenario.
The scenario I chose is simplified: a domain you can easily understand but that provides sufficient
complexity so that using Spring Batch makes sense. Bank statements are an example of common batch
processing. Run nightly, these processes generate statements based on the previous month's
transactions. The example is a derivative of the standard bank statement: a brokerage statement. The
brokerage statement batch process shows how you can use the following features of Spring Batch
together to accomplish the result:
Various input and output options: Among the most significant features of
Spring Batch are the well-abstracted options for reading and writing from a
variety of sources. The brokerage statements obtains input from flat files, a
database, and a web service. On the output side, you write to databases as well
as flat files. A variety of readers and writers are utilized.
Error handling: The worst part about maintaining batch processes is that when
they break, it's typically at 2:00 a.m., and you're the one getting the phone call
to fix the problem. Because of this, robust error handling is a must. The
example statement process covers a number of different scenarios including
logging, skipping records with errors, and retry logic.
Scalability: In the real world, batch processes need to be able to accommodate
large amounts of data. Later in this topic, you use the scalability features of
Spring Batch to tune the batch process so it can process literally millions of
In order to build our batch job we will want a set of requirements to work from. Since we will be
using user stories to define our requirements, we will take a look at the agile development process as a
whole in the next section.
Understanding Agile Development
Before this chapter digs into the individual requirements of the batch process you develop in Chapter 10,
let's spend a little time going over the approach you use to do so. A lot has been said in our industry
about various agile processes; so instead of banking on any previous knowledge you may have of the