Hi everyone,
I have a Hangfire setup with a shared database and multiple Hangfire servers, each responsible for processing a specific queue only.
For example:
'Server1 configuration
Dim options1 = New BackgroundJobServerOptions With {.Queues = New String() {"13661"}, .WorkerCount = 1 }
'Server2 configuration
Dim options2 = New BackgroundJobServerOptions With { .Queues = New String() {"8882"}, .WorkerCount = 1 }
Each recurring job is also assigned to a specific queue when created. For exemple:
RecurringJob.AddOrUpdate(
"13661_MainCompany_z202508051909374380083942",
Sub() JobFactory.processJob(13661, "MainCompany", "Job 1", "z202508051909374380083942"),
"*/10 * * * *",
TimeZoneInfo.FindSystemTimeZoneById(timezone),
"13661"
)
In the Hangfire database, each recurring job has a Queue
field set correctly.
Key: recurring-job:13661_MainCompany_z202508051909374380083942
Queue: 13661
Key: recurring-job:8882_Main_z202508061925402630090307
Queue: 8882
When Server2 is offline, Server1 still enqueues jobs for the recurring job assigned to queue “8882”, even though Server1 is only configured to process queue "13661"
.
I want each Hangfire server to only trigger (enqueue) recurring jobs that belong to the queue it handles. In other words, if a server doesn’t handle queue "8882"
, it should not even create jobs for that queue.
Is there a way to configure this behavior in Hangfire?