Skip to content

Add afterJobSaved method to JobExecutionListener #4851

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
hannosgit opened this issue May 28, 2025 · 1 comment · May be fixed by #4853
Open

Add afterJobSaved method to JobExecutionListener #4851

hannosgit opened this issue May 28, 2025 · 1 comment · May be fixed by #4853
Labels
status: waiting-for-triage Issues that we did not analyse yet type: feature

Comments

@hannosgit
Copy link

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 hannosgit added status: waiting-for-triage Issues that we did not analyse yet type: feature labels May 28, 2025
@therepanic
Copy link

therepanic commented May 28, 2025

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.

hannosgit added a commit to hannosgit/spring-batch that referenced this issue May 31, 2025
hannosgit added a commit to hannosgit/spring-batch that referenced this issue May 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage Issues that we did not analyse yet type: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants