8.3.3. Initial Setup of JSR352-compliant Batch Project

The following is procedures of initial setup of the JSR352-compliant batch project:

  • Generate a JSR352-compliant batch project
  • Confirm communications of the JSR352-compliant batch project

8.3.3.1. Overview of the generated project

The overview of the project generated by this procedure is as follows.

Item Description
Project type Maven project
Project composition Single project composition
DB used H2 Database Engine (embedded in the application)
What is included in the generated project?

The following is included in the generated project:

  • Basic configuration for the JSR352-compliant batch application
  • Batch application for communication confirmation by the batchlet architecture
  • Batch application for communication confirmation by the chunk architecture
  • Application for communication confirmation using the ETL function [1]
  • Initial configuration of the tool that operates in conjunction with Maven (is imported by referring to nablarch-archetype-parent (parent project)).
[1]Since the class to execute ETL exists in Nablarch, the project contains only the configuration file, DTO class and entity class used by ETL.

For relationship with other projects and directories, see Maven Archetype Configuration.

8.3.3.2. Create blank project

Generate a blank project using the archetypes provided by Nablarch.

8.3.3.2.1. Execute the mvn command

Change the current directory to the directory where the blank project (can be any directory) is to be created, and place the following file.

Batch file

After placing the file, specify the necessary parameters in the arguments and execute the bat file.

generateJbatchProject.bat 5u24 <<groupId>> <<artifactId>> <<version>> <<package(optional)>>

The parameters configured in the above command are as follows. If you want to change the version of Nablarch, change 5u24.

Input item Description Configuration example
groupId Group ID (normally, enter the package name) com.example
artifactId Artifact ID myapp-batch-ee
version Version number 0.1.0
package Package (normally the same as group ID) com.example

Important

Item groupId and package are mapped to the Java package name. Use lowercase letters, numbers, and dots for these input values, and do not use hyphens.

If the command ends normally, a blank project is created under the current directory.

8.3.3.3. Communication confirmation

8.3.3.3.1. Automated test

The following unit tests are included in the project generated from the archetype.

Unit test classes Test content
SampleBatchletTest JUnit test for classes with database connection.

Execute the unit test and confirm that the blank project was successfully generated.

Execute the following command.

cd myapp-batch-ee
mvn test

If the execution is successful, the log given below will be output to the console.

(Omitted)
[INFO] ---------------------< com.example:myapp-batch-ee >---------------------
[INFO] Building myapp-batch-ee 0.1.0
[INFO] --------------------------------[ jar ]---------------------------------
(Omitted)
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
(rest is omitted)

8.3.3.3.2. Launch test

The following batch applications are incorporated in the project that is generated.

Job ID Details
sample-batchlet Sample application implemented by the batchlet architecture.
sample-chunk Sample application implemented by the chunk architecture.
sample-etl Sample application of the ETL function provided by Nablarch.

Confirm the communications of the above 3 batch applications and confirm that the blank project has been successfully generated.

8.3.3.3.2.1. Build a batch application

If the current directory is not yet moved to the generated project, move the directory.

cd myapp-batch-ee

Execute the following command to build the batch application.

mvn package

8.3.3.3.2.2. Launch the batch application of the batchlet architecture

The batch application of the batchlet architecture implements the process to delete the data of the SAMPLE_USER table.

Execute the following command.

mvn exec:java -Dexec.mainClass=nablarch.fw.batch.ee.Main -Dexec.args="'sample-batchlet'"

If the execution is successful, the log given below will be output to ./progress.log.

2020-04-28 10:35:27.002 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] start job. job name: [sample-batchlet]
2020-04-28 10:35:27.011 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] start step. job name: [sample-batchlet] step name: [step1]
2020-04-28 10:35:27.247 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish step. job name: [sample-batchlet] step name: [step1] step status: [SUCCESS]
2020-04-28 10:35:27.255 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish job. job name: [sample-batchlet]

Tip

This batchlet deletes all the data in the SAMPLE_USER table. To recover deleted data, execute the Launch an application that uses the ETL function command.

8.3.3.3.2.3. Launch an application that uses the ETL function

The application that uses the ETL function is configured to input data to the SAMPLE_USER table.

Execute the following command.

mvn exec:java -Dexec.mainClass=nablarch.fw.batch.ee.Main -Dexec.args="'sample-etl'"

If the launch is successful, the log given below will be output to ./progress.log.

2020-04-28 10:37:21.921 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] start step. job name: [sample-etl] step name: [load]
2020-04-28 10:37:21.932 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-etl] step name: [load] input count: [10]
2020-04-28 10:37:21.944 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-etl] step name: [load] write table name: [SAMPLE_USER]
2020-04-28 10:37:21.954 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-etl] step name: [load] total tps: [500.00] current tps: [500.00] estimated end time: [2020/04/28 10:37:21.954] remaining count: [0]
2020-04-28 10:37:21.963 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish step. job name: [sample-etl] step name: [load] step status: [COMPLETED]
2020-04-28 10:37:21.973 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish job. job name: [sample-etl]

8.3.3.3.2.4. Launch the batch application of the chunk architecture

The batch application of the chunk architecture implements the process to extract data from the SAMPLE_USER table, edit the data, and output data to a CSV file.

Execute the following command.

mvn exec:java -Dexec.mainClass=nablarch.fw.batch.ee.Main -Dexec.args="'sample-chunk'"

If the launch is successful, the log given below will be output to ./progress.log.

2020-04-28 10:39:46.955 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] start job. job name: [sample-chunk]
2020-04-28 10:39:46.974 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] start step. job name: [sample-chunk] step name: [step1]
2020-04-28 10:39:47.202 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-chunk] step name: [step1] input count: [10]
2020-04-28 10:39:47.235 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-chunk] step name: [step1] total tps: [156.25] current tps: [156.25] estimated end time: [2020/04/28 10:39:47.235] remaining count: [5]
2020-04-28 10:39:47.244 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] job name: [sample-chunk] step name: [step1] total tps: [243.90] current tps: [625.00] estimated end time: [2020/04/28 10:39:47.243] remaining count: [0]
2020-04-28 10:39:47.257 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish step. job name: [sample-chunk] step name: [step1] step status: [COMPLETED]
2020-04-28 10:39:47.263 -INFO- progress [null] boot_proc = [] proc_sys = [batch-ee] req_id = [null] usr_id = [null] finish job. job name: [sample-chunk]

The following data is output to testdata/output/outputdata.csv.

ユーザID,氏名
1,名部楽 一郎
2,名部楽 二郎
3,名部楽 三郎
4,名部楽 四朗
5,名部楽 五郎
6,名部楽 六郎
7,名部楽 七郎
8,名部楽 八郎
9,名部楽 九郎
10,名部楽 十郎

Tip

testdata/output/outputdata.csv is output in UTF-8. When checking the contents of testdata testdata/output/outputdata.csv, open the file with a text editor as the contents will be garbled if opened with excel.

8.3.3.3.2.5. If the communication confirmation fails for some reason

If the communication confirmation fails for some unknown reason, the correct procedure may not have been followed in some part.

If the reason is not known, try again from Create blank project.

8.3.3.3.3. Supplementary notes

For information on the method of confirming the data of H2 and tools included in the blank project, see Initial Setup Procedure Supplementary Information.