Batch Processing Patterns
1. Chunk-Oriented
This is a pattern that is divided into an ItemReader that receives input one record at a time from a DB or file, an ItemProcessor that processes the business logic one record at a time, and an ItemWriter that outputs the result.
-
The general form of a single Step consists of an ItemReader, ItemProcessor, and ItemWriter.
-
Within one transaction, data is read once and then written in units of the specified commit-interval (chunk).
-
For example, if the commit interval is set to 100, based on the input data, the ItemReader and ItemProcessor process 100 records of data, and then the chunk passed to the ItemWriter is written to the DB or file, after which the corresponding transaction is committed.
2. Tasklet
This is a pattern used in batches that perform simple DB CRUD operations or must be committed/rolled back at once.
-
This is a Step type used when implementing simple tasks (such as executing a single DB CRUD statement) or business logic composed of one transaction, and it is implemented using the Tasklet interface, which has the execute() method.
-
Unlike chunk-oriented processing, which performs transaction processing in chunk units within a Step in a batch Job, it has a structure in which only a single transaction is performed when the Step is executed, and it can be used when processing input data with commit/rollback at once.