When the job is complete, you can check your e-mail inbox as shown in Figure 9-8 to see that the
customers have successfully received their e-mails.
Figure 9-8. The result of the e-mail job
Spring Batch provides a full collection of ItemWriters to handle the vast majority of output handling
that you need to be able to do. The next section looks at how you can use the individual features of each
of these ItemWriters together to address more complex output scenarios, such as writing to multiple
places based on a number of scenarios.
As part of your new system, you have the requirement to extract customer data into two different
formats. You need an XML file for the Sale's department's customer relationship management (CRM)
application. You also need a CSV for the billing department's database import system. The issue is, you
expect to extract one million customers.
Using the tools discussed up to this point, you would be stuck looping through the one million items
twice (once for a step that outputs the XML file and once for the step that outputs the CSV file) or
creating a custom ItemWriter implementation to write to each file as an item is processed. Neither
option is what you're looking for. The first will take too long, tying up resources; and the other requires
you to code and test something that the framework should already provide. Fortunately for you, it does.
This section looks at how you can use the various composite ItemWriters available in Spring Batch to
address more complex output scenarios.