Initial Setup of Jakarta Batch-compliant Batch Project¶
The following is procedures of initial setup of the Jakarta Batch-compliant batch project:
- Generate a Jakarta Batch-compliant batch project
- Confirm communications of the Jakarta Batch-compliant batch project
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:
|
For relationship with other projects and directories, see Maven Archetype Configuration.
Create blank project¶
Generate a blank project using the archetypes provided by Nablarch.
Execute the mvn command¶
Use Maven Archetype Plugin(external site) to generate a blank project.
Change the current directory to the directory where the blank project (can be any directory) is to be created.
Execute the following command.
mvn archetype:generate -DarchetypeGroupId=com.nablarch.archetype -DarchetypeArtifactId=nablarch-batch-ee-archetype -DarchetypeVersion=6u3
The version of Nablarch used in the above command is 6u3. If you want to change the version, change the following parameters.
Set value | Description |
---|---|
archetypeVersion | Specify the version of the archetype you wish to use. (Nablarch 6u2 or later must be specified) |
Enter project information¶
When the above command is executed, you will be asked to enter the following information about the blank project to be generated.
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.
When you have finished entering project information, Y: : will appear.
- Enter 「Y」 if you want to generate a template based on the information you have entered.
- Enter 「N」 if you wish to redo the project information entry.
If the command ends normally, a blank project is created under the current directory.
Communication confirmation¶
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)
Launch test¶
The following batch applications are incorporated in the project that is generated.
Job ID | Details |
---|---|
sample-chunk | Sample application implemented by the chunk architecture. |
sample-batchlet | Sample application implemented by the batchlet architecture. |
Confirm the communications of the above 2 batch applications and confirm that the blank project has been successfully generated.
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
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.
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, refer to Project structure and copy “SAMPLE.mv.db.org” to “SAMPLE.mv.db”.
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.
Configure the database¶
The blank project is initially configured to use the H2 Database Engine. To change the RDBMS to be used, refer to Procedure for Changing the RDBMS used for the configuration.
In addition, to generate and execute DDL from ER diagrams and automatically generate entity classes, you need to initialize and run gsp-dba-maven-plugin. For details, see Initial Configuration Method of gsp-dba-maven-plugin (DBA Work Support Tool).
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.