Reputation: 798
A job in Spring-batch will save status on the job in the table BATCH_JOB_EXECUTION
. Is there an easy way (beside reading the column START_TIME
in the table itself) to get the start time of the job from a Step?
Upvotes: 1
Views: 1304
Reputation: 31710
Yes, the idea to get access to the job execution from the step execution. For example:
@Bean
public Step step() {
return stepBuilderFactory.get("step")
.tasklet(new Tasklet() {
@Override
public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
JobExecution jobExecution = chunkContext.getStepContext().getStepExecution().getJobExecution();
System.out.println("hello world! Job started at: " + jobExecution.getStartTime());
return RepeatStatus.FINISHED;
}
})
.build();
}
Upvotes: 2