We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

Configuring and using Multiple Queues

Hi all,
i’m in trouble with configuring and using multiple queues.

Here is the content of my startup class:

var options = new DashboardOptions
            {
                AppPath = VirtualPathUtility.ToAbsolute("~")
            };
            app.UseHangfireDashboard("/jobs", options);

            var queues = new BackgroundJobServerOptions
            {
                Queues = new[] { "high", "normal" }
            };

            app.UseHangfireServer(queues);

The server starts correctly and from the dashboard i can see the queues.

But when I try to enqueue a process, hangfire always sets the jobs into the default queue.
This is the call to the method:

BackgroundJob
  .Enqueue<IFileConverterService>(
    x => x.CreateSlides(docId, folderpath, priority));

This is the method implementation:

 public class FileConverterService : IFileConverterService
    {
        [Queue("high")]
       public void CreateSlides(Guid documentId, string folderPath, int priority)
       {
           //my stuff
       }
   }

What I’m missing? Thanks :smile:

I could not find any problem here. Hope your problem could be solved soon.

Hi all, I’ve solved the problem.

In the startup configuration it seems it’s mandatory to define a default queue as shown

var queues = new BackgroundJobServerOptions
{
       Queues = new[] { "high", "default" }
};

Then implement a method with the Queue attribute and another one without it.

[Queue("high")]
public void CreateSlidesWithHighPriority(Guid documentId, string folderPath, int priority)
{
     //my code
}

public void CreateSlidesWithLowPriority(Guid documentId, string folderPath, int priority)
{
    //my code
}

Now all works perfectly.