Concurrency issue

Hi there !

We are using HangFire Pro with the Redis storage backend.

Right now we have the case where we have one method

CompileLeafletFlightSync(string id,IJobCancellationToken cancellationToken);

That gets enqueued as a background job with different ids.
This is the invocation:

backgroundJobClient.Enqueue(l => l.CompileSync(id,JobCancellationToken.Null));

Where id is different for each item obviously.

We are running multiple servers that process background jobs.

Now we are running into the problem that the SAME job ( with the same id parameter value ) gets processed by multiple servers at the same time which is not a very good behaviour for us.

Our ideal solution would be that a unique job with the same id gets processed by one server at a time only, but still that jobs with different id values would get processed in parallel.

Is this doable at all with Hangfire ?

Here is the dashboard output for one such job:

Seems like what you need is duplicate job detection, which is possible using Hangfire filters (to add, check & remove job fingerprints based on method arguments). Sample code by Hangfire developer: