Reputation: 61
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?
Upvotes: 1
Views: 1547
Reputation: 61
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.
Upvotes: 2