Batch Meta-Data
Spring Batch saves information related to batch operations in your application in two different ways:
- Relational Database
- Volatile (in-memory map)
Storing these details allows Spring Batch to track statuses of job executions. Also the various readers and writers are stateful in nature; this necessitates persisting these meta-data in some form so that they can be used by Spring Batch to do the appropriate operations as required.
The Spring Batch Meta-Data tables very closely match the Domain objects that represent them in Java. The one-to-one relationship between the domain object and the table is as shown in Table 23-3 below.
Table 23-3. Domain object name and database table mapping in Spring Batch
Domain Object | Database Table |
JobInstance | BATCH_JOB_INSTANCE |
JobExecution | BATCH_JOB_EXECUTION |
JobParameters | BATCH_JOB_PARAMS |
Job’s ExecutionContext | BATCH_JOB_EXECUTION_CONTEXT |
StepExecution | BATCH_STEP_EXECUTION |
Step’s ExecutionContext | BATCH_STEP_EXECUTION_CONTEXT |
The JobRepository is responsible for saving and storing each Java object into its correct database table. JobRepository is purely an internal interface which the users need not know at all. But this has to be defined in the Spring configuration file as show in Listing 23-29 below.
Listing 23-29. JobRepository declaration in Spring configuration file using Spring Batch namespace
1 2 3 4 5 6 7 8 9 |
<beans …> … <batch:job-repository id="jobRepository"/> … </beans> |
Figure 23-17 below shows how the various Spring Batch meta-data is filled in so that the database tables are filled with details required.
Figure 23-17. Spring Batch meta-data details getting filled in by Spring Batch
Figure 23-18 below shows the relationship between various database tables in Spring Batch which will be used by the various components to become stateful in nature.
Figure 23-18. Spring Batch meta-data database table schema details (Spring Batch Documentation)
Page Visitors: 26009
Tomcy John
Latest posts by Tomcy John (see all)
- A Guide to Continuous Improvement for Architects - February 2, 2023
- Cloud-first Architecture Strategy - January 26, 2023
- Architecture Strategy and how to create One - January 24, 2023
Thanks for sharing the information but what’s the difference between CursorItemReader’s setFetchSize() and PagingItemReader’s setPageSize()? isn’t it the same?
Please provide an example for StoredProcedureItem Reader – which returns cursor and how to process cursor in processor – I am new to Spring Batch as part of my work I need to invoke Oracle Stored proc which takes one param as input and returns result set which I need to process in Spring Batch Processor.
Thanks
Laxmi