Adding dynamic queues to service post IServiceCollection setup

Tags: #<Tag:0x00007fb5040f8410>

I know that I can add jobs to non “default” queues by the following:

var enqueuedState = new EnqueuedState
        Queue = "custom-queue",
 BackgroundJobs.Create(() => RunTask(resourceUnit), enqueuedState);

I know that for this to work, I need to setup the server ahead of time like this:

    services.AddHangfireServer(configuration => configuration
        .Queues = new string[]
            { "custom-queue" });

But this only works where I know the queue names ahead of time. I have a case where post theIServiceCollection setup, I learn about new queues that need to be created… i.e. as users come online in different regions, I want to be able to create independent queues in each region (the names of the queues looking something like “custom-queue-australia”, “custom-queue-america”, etc).

How do you add more queues to the default service post its initialization?

@avanderhoorn did you figure it out? I’m interested in the same thing.