Chapter 6. Writing data

 

This chapter covers

  • Introducing item-writing concepts
  • Writing to files, databases, and JMS
  • Sending emails
  • Implementing custom writers
  • Implementing advanced writers

In chapter 5, we learned how to read data with Spring Batch. In this chapter, we focus on another core feature of the batch process: writing.

Reading input items takes place at the beginning of a chunk-oriented step and writing items takes place at the end. In Spring Batch, a writer is responsible for data persistence.

We start by looking at data-writing concepts. We use our case study to illustrate how to write data into flat files, XML files, and relational databases using both JDBC and ORM (Object Relational Mapping). Spring Batch provides various implementations out of the box for these targets, but it may be necessary to create your own writer implementations, which we demonstrate. If you already have legacy services that produce or save data, Spring Batch can delegate to and reuse these services. We also learn how to write to a Java Message Service (JMS) queue and send emails. Finally, we discuss some advanced writing techniques.

6.1. Data-writing concepts

Here we look at core concepts of writing with Spring Batch, particularly writing in a chunk-oriented tasklet. Figure 6.1 shows what we already know from chapter 5, but we focus now on writing data.

6.2. Writing files

6.3. Writing to databases

6.4. Adapting existing services for reuse

6.5. Writing to JMS

6.6. Sending email messages

6.7. Implementing custom item writers

6.8. Advanced writing techniques

6.9. Summary

sitemap