I saw the api of JobInstanceDao and try to get the JobInstance by calling getJobInstance(Job job, JobParameters jobParameters). In this way, I must know the JobParameter, however, we do not know job parameters when people monitor their job which was run by spring batch automatically, and they only know the name of job.
the steps I want to do to monitor a batch job are
- query all job instances according to job name,
- get a job instance object according to job_instance_id
- query the job status, step status for a certain job instance
I take a look at the table BATCH_JOB_INSTANCE and I notice that we can get JobInstance by passing JOB_INSTANCE_ID, that becomes more easy since we do not need to remember job parameters.
Could we provide this API
List getJobInstances(String jobname, int maxReturnNumber)
in the next version of spring batch?
JobInstance getJobInstance(String JOB_INSTANCE_ID)