Companion code for "Spring Batch on Boot 4.1: Jobs, Steps, Chunk Processing and Restartability". A productImportJob configured three ways by profile against a poisoned CSV row, run as real java -jar processes (not just JUnit) so the restart story is genuine: a chunk fails and rolls back, the process exits, a brand-new JVM against the same file-based H2 database resumes at the exact next unread row (READ_COUNT 20, not 60) and completes. Findings the build pins: - StepBuilder.chunk(int, PlatformTransactionManager) still compiles in Batch 6.0.5 but returns the legacy SimpleStepBuilder; chunk(int) returns the new ChunkOrientedStepBuilder, and only the latter is used here. - Two different ExecutionContext classes now exist in two different packages (infrastructure.item vs core.repository.persistence) with different shapes. - spring-boot-starter-batch alone gives a resourceless JobRepository that forgets every JobInstance the moment the JVM exits; spring-boot-starter- batch-jdbc is what makes the restart demo possible at all, demonstrated by excluding BatchJdbcAutoConfiguration and watching a "restart" collide with the previous run's own data instead of resuming it. - A migration-guide summary claiming CommandLineJobRunner was removed in 6.0 is wrong -- javap against the real jar shows @Deprecated(forRemoval=true), not removed. - RepeatStatus moved from core.repeat to infrastructure.repeat, caught by the compiler rather than by reading docs. 11 documentation chapters, 10 captured transcripts (unit tests, javap output, and real two-JVM scenario runs), all regenerated by scripts/run-all.sh.
11 lines
581 B
SQL
11 lines
581 B
SQL
-- Application table, separate from the BATCH_* tables that BatchJdbcAutoConfiguration
|
|
-- creates via spring.batch.jdbc.initialize-schema. The UNIQUE constraint on sku is what turns
|
|
-- the poisoned duplicate row into a real DataIntegrityViolationException at chunk-commit time
|
|
-- rather than something the processor could have caught by looking at one row in isolation.
|
|
CREATE TABLE IF NOT EXISTS PRODUCT (
|
|
id BIGINT AUTO_INCREMENT PRIMARY KEY,
|
|
sku VARCHAR(16) NOT NULL UNIQUE,
|
|
name VARCHAR(200) NOT NULL,
|
|
price_cents BIGINT NOT NULL
|
|
);
|