Writing XML for Batch Jobs
A unit step of a batch consists of ItemReader, ItemProcessor, and ItemWriter, and a batch job is composed of one or more steps in a flow. Since the minimum unit of a batch that can be executed externally is a batch job (Job), the user defines the execution of a batch job by describing "Job" in XML as follows.
(1) Writing XML
Create an XML file under META-INF of the batch application, using the batch job (Job) name as the file name.
The following example is the XML configuration of a batch job (Job) written so that the batch described above can be executed.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:batch-int="http://www.springframework.org/schema/batch-integration"
xsi:schemaLocation="http://www.bankwareglobal.com/schema/batchex http://www.bankwareglobal.com/schema/batchex/spring-batch-ex.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/batch-integration http://www.springframework.org/schema/batch-integration/spring-batch-integration.xsd">
<import resource="classpath:JobConfig.xml"/>
<job-component xmlns="http://www.bankwareglobal.com/schema/batchex" id="jobcomp" with-dependon="true">
<base-package name="bxm.dft.smp.batch.bean">
<include name="MSmpDBToDBBtch"/>
</base-package>
</job-component>
<!--
* BatchJob : DB TO DB Sample
* BatchStep :
- JSmpDBToDB100 : DB TO DB process
-->
<job id="JSmpDBToDB" xmlns="http://www.bankwareglobal.com/schema/batchex">
<step id="JSmpDBToDB100" parent="parentStep">
<tasklet>
<chunk reader="MSmpDBToDBBtch" processor="MSmpDBToDBBtch" writer="MSmpDBToDBBtch"/>
</tasklet>
</step>
</job>
</beans>
The following is a description of how to write the batch job (Job) XML, using the above process as an example.
1. Specify the "job id", that is, the batch job (Job) ID according to the naming conventions.
2. Define the first Step and specify the "Step Id" according to the naming conventions. In the example currently in use, the batch job (Job) is composed with only a single step.
3. Define the actual work to be performed in the Step as a "tasklet".
4. To commit processing results by section, use "chunk" and specify in the "reader", "processor", and "writer" items the bean names created in the above process.