C H A P T E R 9
It's amazing what computers can do. The numbers they can crunch. The images they can process. Yet it
doesn't mean a thing unless the computer can communicate what it has done via its output. ItemWriters
are the output facility for Spring Batch. And when you need a format to output the results of the Spring
Batch process, Spring Batch delivers. In this chapter, you look at the different types of ItemWriters
provided by Spring Batch as well as how to develop ItemWriters for situations that are more specific to
your needs. Topics discussed include the following:
Introduction to ItemWriters: Similar to the ItemReaders at the other end of step
execution, ItemWriters have their own special nuances. This chapter talks about
how ItemWriters work from a high level.
File-based ItemWriters: File-based output is the easiest method to set up and is
one of the most common forms used in batch processing. Because of this, you
begin your exploration of ItemWriters by looking at writing to flat files as well as
Database ItemWriters: The relational database is king in the enterprise when it
comes to data storage. However, databases create their own unique challenges
when you're working with high volumes of data. You look at how Spring Batch
handles these challenges with its unique architecture.
Alternative output destination ItemWriters: Files and databases aren't the only
media to which enterprise software outputs. Systems send e-mails, write to JMS
endpoints, and save data via other systems. This section looks at some of the less
common but still very useful output methods that Spring Batch supports.
Multipart ItemWriters : Unlike reading, where data typically comes from a single
source, it's common to send output to multiple sources. Spring Batch provides
ways to write to multiple systems as well as structure a single ItemWriter as a
collaborative effort of multiple ItemWriters. This section looks at ItemWriters
tasked with working with either multiple resources or multiple output formats.
• Statement writers: This chapter finishes the development of the statement job by
implementing the required writers for each step.
To start with ItemWriters, let's look at how they work and how they fit into a step.