I am looking to implement Hangfire within an Asp.Net Core application.
However, I’m struggling to understand how best to prevent the user from creating duplicate Hangfire “Fire-and-Forget” jobs.
Say the user, via the app, creates a job that does some processing relating to a specific client. The process may take several minutes to complete. I want to be able to prevent the user from creating another job for the same client while there are other jobs for that client still being processed by Hangfire (i.e. there can only be 1 processing job for a specific client at any one time, although several different clients could also each have their own job being processed).
I need a way to attach additional meta-data (in this example, the client id) to each job as it is created, which I can then use to interrogate the jobs currently processing in Hangfire to see if any of them relate to the client id in question.
It seems like such a basic feature that would prove so useful for such scenarios, but I’m coming to the conclusion that such a thing isn’t supported, which surprises me.
… Unless you know different.
Hangfire looks great, and I’m keen to use it, but this might be a show-stopper for me.
Any advice would be greatly received.