We are leaving Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Filter to handle failed jobs

Hey All,

I have created a filter
JobFailureFilter

It is supposed to check if a job goes to failed state, and notify the client after having retried 10 times.

I have registered the filter like this:
GlobalJobFilters.Filters.Add(new JobFailureFilter(serviceProvider.GetService<IJobManager>(), serviceProvider.GetService<IStatusReportingClient>()));

The filter implements all of the interfaces:
JobFilterAttribute,IClientFilter, IServerFilter, IElectStateFilter, IApplyStateFilter

But my problem is that after the 10’th attempt, it does not enter
public void OnStateApplied(ApplyStateContext context, IWriteOnlyTransaction transaction)

it does enter OnStateApplied when i requeue the job from the dashboard, with the Enqueued state, but when the job throws an exception, it does not change the state to failed, but the job is in failed state in the dashboard.

I have also tried to do it in OnStateElection but it does not enter any of the interface methods after the job throws an exception