Reputation: 319
I have 2 hangfire instances/servers running. Both point to the same hangfire database. How do I restrict one of the hangfire instance to pick up only jobs from a specific queue and ignore other queues?
Thanks
Upvotes: 2
Views: 1691
Reputation: 8053
When you start your instance, you can provide a list of queues to be watched by the server:
app.UseHangfireServer(new BackgroundJobServerOptions()
{
// order defines priority
// beware that queue names should be lowercase only
Queues = new [] { "critical", "default", "myqueue" }
});
Upvotes: 5
Reputation: 102
Believe the Hangfire servers will poll the registered queues for jobs, so first come first serverd if you have the same queue registered with multiple servers.
As mentioned above, just have some queues on each server with unique queue names, as this is what Hangfire used to determine where it gets processed.
For instance, in my case I have 1 server for general maintenance queues applicable to all servers and the app in general, whereas the environment servers contain queues where the jobs target environment specific tasks.
Upvotes: 2