BatchJob - BatchJob still works when the server is stopped

When the BJ is currently starting up, and if the server is STOPPED, the BATCH JOB status in Spring Batch Admin still shows its RUNNING even after the server stops, it should be FAILED

Please help on this? Do we need to handle it manually or can we get it out of the box. Need help with this?

+1
source share
1 answer

task repository (database implementation) reflects the last “known” state. therefore, in the case when the work was performed and the JVM crashed, it will never be updated in the database.

if the database is not “synchronized” with the JVM, then the process should be manual, for it, it seems, there is no ready-made solution. the easiest solution would be to run a script at startup, which checked the package tables for any RUNNING jobs, and then “failed”.

update batch_job_execution set STATUS = 'FAILED', EXIT_CODE = 'FAILED', EXIT_MESSAGE = 'FORCED UPDATE' where job_execution_id in (select job_execution_id from batch_job_execution where status = 'RUNNING'); 

One thing you might want to consider in this situation is that the JobRepository tables and related jobs are shared with another JVM. in this case, you might want to make a pass, which also evaluates whether the work is still outside the maximum duration of any story that it has. (subsection with max () end_time - create_time for the same job_name)

+1
source

All Articles