Issue
I am writing a Spring Batch process (Spring boot 2.x.x). The job selects some rows from a table based on the last update date -
(select * from tablename where last_upd_dt >= :lastruntime).
The :lastruntime is the date of the last (successfully) completed run of the job. I am trying to grab this date from the beforeJob method in the Listener class using JobListener/JobExecutionListener.
Is there a way to leverage the classes Spring Batch framework offers? Else I will have to write and retrieve this info from another table.
Solution
You can use the JobExplorer API. It allows you to get the job executions of your job instance. Once you get that, you can filter the result as needed and get the start/end date from the JobExecution
object.
Answered By - Mahmoud Ben Hassine
Answer Checked By - Terry (JavaFixing Volunteer)