Spring-Batch Tutorial: Guide For Application Developers
Spring-Batch Tutorial: Guide For Application Developers
Agenda
Hello world! job Simple job programming a Tasklet directly Common job weaving standard components Sample jobs
</bean>
</bean>
Samples overview
Samples project contains simple batch jobs illustrating various capabilities of the Spring-Batch framework See the folder src/main/resources/jobs for job configuration files See src/test/java, package org.springframework.batch.sample for tests which launch the jobs and check the expected results
simpleTaskletJob.xml
Straightforwardly implemented Tasklet, similar to the Simple Job example All-in-one solution to help understand tasklets execution logic Standard solutions are more modular, which makes them more flexible and reusable, but also less straightforward to understand
fixedLengthImportJob.xml
Clean separation of reading input and processing data (standard from now on) Typical scenario of importing data from a fixed-length file to database Custom DAO used for output
multilineOrderJob.xml
Handling of complex file format, both reading input and writing output Single record spans multiple lines and has nested records Custom ItemProvider and ItemProcessor implementations handling non-standard file format
tradeJob.xml
shows a reasonably complex scenario, that would resemble the real-life usage of the framework 3 steps:
trade records are imported from file to database customer account balance is adjusted report about customers is exported to a file
compositeProcessorSample.xml
Parallel writing to multiple outputs Example usage of composite ItemProcessor with an injected list of ItemProcessors
restartSample.xml
Simulates restart scenario, where the job crashes on first run and succeeds after being restarted Uses hacked tasklet that throws exception after reading a given number of records