ItemReader
and an ItemWriter
. Spring Batch collects items one at a time from the item reader
into a chunk, where the chunk size is configurable. Spring Batch then sends the chunk to the item writer and goes back to using the item reader
to create another chunk, and so on until the input is exhausted. This is what we call chunk processing.ItemProcessor
interface. Because item processing in Spring Batch is optional, the illustration of chunk processing shown in the first figure is still valid. The below figure illustrates chunk processing combined with item processing. ItemProcessor
? You can perform any transformations you need on each item before it is sent to the ItemWriter
. This is where we implement the logic to transform the data from the input format into the format expected by the target system. Spring Batch also lets you validate and filter an input item; if you return null
from the ItemProcessor
method process, processing for that item will stop and the item will not be inserted into the database.FlatFileItemReader
class to read records from a flat file. To use a FlatFileItemReader
, you need to configure some Spring beans and implement a component that creates domain objects from what the FlatFileItemReader reads; Spring Batch will handle the rest. You can kiss all your old I/O boilerplate code goodbye and focus on the structure of the data and how to exploit that data.