Spring Batch batch data table

Table of contents

introduction

overview

batch_job_instance table

batch_job_execution table

batch_job_execution_context表

batch_job_execution_params表

btch_step_execution表

batch_step_execution_context表

H2 in-memory database

Turn to video version


introduction

Next to the previous article: Spring Batch step object-return status-ExitStatus , after understanding the return status ExitStatus status class, let’s learn about the core data table of Spring Batch batch processing

overview

In the learning phase, Spring Batch data storage can be stored in two ways, 1: H2 memory database 2: relational database. Choice 1 is easy to say, basically we don’t need to do too much intervention, and choice 2 is the same, but we can use the database visualization tool to view the data table to help us better understand the execution process or principle of springbatch.

When we choose the database method to store batch data, Spring Batch will automatically create 9 tables at startup, storing them respectively: JobExecution, JobContext, JobParameters, JobInstance, JobExecution id sequence, Job id sequence, StepExecution, StepContext/ChunkContext, StepExecution id sequence and other objects. Spring Batch provides the JobRepository component to implement CRUD operations on these tables, and these operations are basically encapsulated in steps, blocks, and job api operations, which do not require us to intervene too much, so just understand the content of this chapter.

batch_job_instance table

 When the job is executed for the first time, a unique JobInstance object will be generated according to the job name and identification parameters, and the batch_job_instance table will record a message representing the job instance.

field describe
JOB_INSTANCE_ID Job Instance Primary Key
VERSION The version number controlled by optimistic locking
JOB_NAME job name
JOB_KEY The hash value of the job name and identifying parameters can uniquely identify a job instance

batch_job_execution table

Every time a job is started, a JobExecution object is created, which represents a job execution, and the object record is stored in the batch_job_execution table.

field describe
JOB_EXECUTION_ID job execution object primary key
VERSION The version number controlled by optimistic locking
JOB_INSTANCE_ID JobInstanceId (which JobInstance belongs to)
CREATE_TIME record creation time
START_TIME Job execution start time
END_TIME Job execution end time
STATUS Batch status of job execution
EXIT_CODE The exit code of the job execution
EXIT_MESSAGE Exit message for job execution
LAST_UPDATED The time the record was last updated

batch_job_execution_context表

batch_job_execution_context is used to save the ExecutionContext object data corresponding to the JobContext.

field describe
JOB_EXECUTION_ID job execution object primary key
SHORT_CONTEXT ExecutionContext string reduced version after serialization
SERIALIZED_CONTEXT ExecutionContext string after serialization

batch_job_execution_params表

When the job is started, use the location where the identifying parameters are saved: batch_job_execution_params, one parameter and one record

 

field describe
JOB_EXECUTION_ID job execution object primary key
TYPE_CODE tag parameter type
KEY_NAME parameter name
STRING_VALUE There is a value when the parameter type is String
DATE_VALUE There is a value when the parameter type is Date
LONG_VAL There is a value when the parameter type is LONG
DOUBLE_VAL There is a value when the parameter type is DOUBLE
IDENTIFYING Used to mark whether the parameter is an identifying parameter

btch_step_execution表

Job starts, steps are executed, and the execution information of each step is saved in the tch_step_execution table

 

field describe
STEP_EXECUTION_ID step execution object id
VERSION Optimistic locking control version number
STEP_NAME step name
JOB_EXECUTION_ID job execution object id
START_TIME The start time of the step execution
END_TIME The end time of the step execution
STATUS Step Batch Status
COMMIT_COUNT Number of transactions committed in step execution
READ_COUNT Number of entries read
FILTER_COUNT The number of entries filtered out because the ItemProcessor returned null
WRITE_COUNT Number of entries written
READ_SKIP_COUNT The number of items skipped due to an exception thrown in the ItemReader
PROCESS_SKIP_COUNT The number of items skipped due to an exception thrown in the ItemProcessor
WRITE_SKIP_COUNT The number of entries skipped due to an exception thrown in the ItemWriter
ROLLBACK_COUNT Number of transactions rolled back during step execution
EXIT_CODE the step's exit code
EXT_MESSAGE Information returned by step execution
LAST_UPDATE Last updated record time

batch_step_execution_context表

The data table saved by the ExecutionContext corresponding to the StepContext object: batch_step_execution_context

field describe
STEP_EXECUTION_ID step execution object id
SHORT_CONTEXT ExecutionContext string reduced version after serialization
SERIALIZED_CONTEXT ExecutionContext string after serialization

H2 in-memory database

 The operation of the job refers to the control of the job, including job start, job stop, job exception handling, job restart processing, and so on.

At this point, this article is over. If you want to know what will happen next, please listen to the next chapter to break it down~

Turn to video version

If you are not addicted to reading text, you can switch to the video version: Spring Batch efficient batch processing framework in practice

 

 

Guess you like

Origin blog.csdn.net/langfeiyes/article/details/128880267