Job Repository - Spring Batch Part 3
Spring Batch's Job Repository does the work of Scheduling and Interacting with Jobs. It also manages failures and reruns. As we saw in the previous blog, a Job can have multiple steps - Job Repository handles it all. It does all of the management using a few tables in the database.
Till now, we have been using the h2 in-memory database - which actually creates a new instance of the db everytime we restart the application. Lets use standalone h2 db, so we can take a look at the tables involved and the data it holds.
Git repo link: https://github.com/ricsr/spring-batch-demo/tree/exercise_03
Download H2 DB and open the console.
Edit your application.properties with the following as reference:
spring.datasource.url=jdbc:h2:tcp://localhost/~/test
spring.datasource.driverClassName=org.h2.Driver
spring.datasource.username=sa
spring.datasource.password=test
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
Start your application. Once the application runs successfully, refresh your H2 DB console, and you should see the following tables created:
BATCH_JOB_EXECUTION
BATCH_STEP_EXECUTION
BATCH_STEP_EXECUTION_CONTEXT
BATCH_JOB_EXECUTION_CONTEXT
BATCH_JOB_EXECUTION_PARAMS
BATCH_JOB_INSTANCE
Lets look at the output:
It has details of the job executed and the steps of the Job.
Try this: Are you able to rerun the application again?
Git Repo Link: https://github.com/ricsr/spring-batch-demo/tree/exercise_03
Comments