I am using Hangfire using SQL Server and MSMQ.
I have created a custom attribute as follows
public class CustomJobFilterAttribute : JobFilterAttribute, IElectStateFilter
and within OnStateElection(ElectStateContext context) I have a variable
var failedState = context.CandidateState as FailedState;
My method that processes the job throws an exception. The exception is visible in the Hangfire Dashboard under Failed State, but failedState variable within the attribute always remain null.
On attaching a debugger, I see that context.CandidateState is set to ProcessingState right after the exception and never to FailedState.
What I am doing wrong?