spring-batch icon indicating copy to clipboard operation
spring-batch copied to clipboard

Add afterJobSaved method to JobExecutionListener

Open hannosgit opened this issue 5 months ago • 1 comments

Current Behavior

Currently there is a afterJob method in JobExecutionListener that is called after the job completes but BEFORE the job metadata (status) is actually saved into the database. We currently use this method to send a message to RabbitMQ with the status of the job but there is the edge case that we send the message with the new status but the transaction rolls back in the end. This would lead to the case that the status in the message and the status in the DB do not match.

Proposed Feature

Additional afterJobSaved method in JobExecutionListener or configurable afterJob method that is only called AFTER the job status is persisted.

hannosgit avatar May 28 '25 09:05 hannosgit

I think this is a very useful feature and I’d be happy to implement it. Adding a new default method to the JobExecutionListener interface would address @hannosgit’s use case perfectly.

Would introducing a backward‑compatible change like this (i.e. a new default method) be acceptable in an upcoming minor release? @fmbenhassine I’d appreciate your guidance.

therepanic avatar May 28 '25 11:05 therepanic

Closed as this should be fixed by https://github.com/spring-projects/spring-batch/commit/36068b5db84ff242032e9b00515454a84e0745d2

hannosgit avatar Nov 13 '25 15:11 hannosgit