Description
Hello,
I have a custom IApplyStateFilter that is used in all my Hangfire servers. In the OnStateApplied implementation I send a SignalR notification to registered clients. Sometimes a client cannot receive the job (and associated data) as the job is not in the expected state, when this is implemented like this:
JobStorage.Current.GetMonitoringApi().SuccededJobs
.
This is because OnStateApplied is invoked before the database transaction is executed (this is also documented somewhere). Persistance is done by the CoreStateMachine after OnStateApplied:
The only way to notify my clients after the transaction seems to require custom IStateHandler (each corresponding to a Hangfire built-in state) which invoke a a custom OnStatePersisted Command in the Apply method.
Is this the right approach or do you see a better solution?
Best regards