Book Image

Spring Batch Essentials

By : P. Raja Malleswara Rao
Book Image

Spring Batch Essentials

By: P. Raja Malleswara Rao

Overview of this book

<p>Spring Batch is an open source, lightweight, and comprehensive solution designed to enable the development of robust batch applications that are vital for enterprise operations.</p> <p>Packed with real-world examples, this book starts with an insight into the batch applications and Spring Batch offerings. After exploring the architecture and key components, you will learn how to develop and execute a batch application. While gaining insights on the essential configurations and execution techniques for batch jobs, you will learn about the key technical implementations of the read, write, and processing features for different forms of data. Next, you will move on to the key features such as transaction management, job flows, job monitoring, and data sharing across the steps of the executing jobs. Finally, you will learn how Spring Batch can integrate with diverse enterprise technologies and facilitate optimization and performance improvement with scaling and partitioning techniques.</p>
Table of Contents (17 chapters)
Spring Batch Essentials
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

ItemReader


Spring Batch provides an interface in the form of ItemReader to read bulk data from different forms, which include the following:

  • Flat files: These are typically of two types: fixed width and delimited character-based files

  • XML: This format is used for different forms of application data

  • Database: This maintains a set of records of similar or different groups of information

The following is the definition of the ItemReader interface:

public interface ItemReader<T> {

T read() throws Exception, UnexpectedInputException, ParseException;

}

Let's examine how ItemReader can help us with reading different formats.

Reading data from flat files

Flat files are configured in two formats, namely, fixed width and delimited. Fixed width files have each field detail configured with a predefined fixed width, whereas the delimited files have fields with a specific character (or tab in general) used to delimit them from the other fields.

Fixed width file

A fixed width file generally has a predefined...