After a job failed finally no matter if it's out of retries or it's a ProblematicExceptionAndMustNotRetry, I want to react on it. Is there any hook I haven't seen so far? Currently I'm using a CustomRetryFilter as follows:
public class CustomRetryFilter extends RetryFilter {
@Override
public void onStateElection(Job job, JobState newState) {
if (this.isFailed(newState)) {
if (!this.isProblematicExceptionAndMustNotRetry(newState)
&& !this.maxAmountOfRetriesReached(job)) {
job.scheduleAt(Instant.now().plusSeconds(this.getSecondsToAdd(job)),
String.format("Retry %d of %d", this.getFailureCount(job), this.getMaxNumberOfRetries(job)));
} else {
// Publish event
}
}
}
}
What is best practice for such a scenario?
No, this is currently the way to do it.
I'll add a feature request for it.