Some batch processes need to read or write to a database schema, as required per step execution. This recipe will be for a new way of writing a batch process that involves MySQL database transactions.
Using the core components of Spring Batch 4 of the previous recipe, let's design a short-lived synchronous batch process that reads Employee
records from an existing table, and writes some items to another table of the same database and also to an XML file.
Let's now implement a blocking batch transaction that reads data from a database:
- Create a separate Spring Boot 2.0 application,
ch11-batch-db
, and add the same starter POM dependencies used in the previous recipe, emphasizing thespring-boot-starter-batch
andspring-oxm
. - Create a bootstrap class inside its core package,
org.packt.process.core
, that enables batch processing:
@SpringBootApplication @EnableBatchProcessing public class BatchProcessBootApplication { ...