Chapter 5. Reading data

 

This chapter covers

  • Reading input data
  • Reading from files
  • Reading from databases
  • Reading from Java Message Service and other sources
  • Implementing custom readers

In the previous two chapters, we concentrated on configuring and launching batch jobs. It’s now time to dig into the features at the heart of batch processes. As described in chapter 2, Spring Batch provides types for batch processes based on the concepts of job and step. A job uses a tasklet to implement chunk processing. Chunk-oriented processing allows jobs to implement efficiently the most common batch processing tasks: reading, processing, and writing.

We focus here on the first step of this process, reading. We describe general concepts and types implemented by Spring Batch. These built-in types are the foundation used to support the most common use cases. Spring Batch can use different data sources as input to batch processes. Data sources correspond to flat files, XML, and JavaScript Serialized Object Notation (JSON). Spring Batch also supports other types of data sources, such as Java Message Service (JMS), in the message-oriented middleware world.

In some cases, the Spring Batch built-in implementations aren’t enough, and it’s necessary to create custom implementations. Because Spring Batch is open source, implementing and extending core types for reading is easily achievable.

5.1. Data reading concepts

5.2. Reading flat files

5.3. Reading XML files

5.4. Reading file sets

5.5. Reading from relational databases

5.6. Using other input sources

5.7. Implementing custom readers

5.8. Summary

sitemap