Ewerton
Ewerton

Reputation: 4523

How to force Hangfire to process the queue right now?

I have a queue of fire and forget jobs and my queue is configured to execute every 10 minutes, like this:

var options = new SqlServerStorageOptions
{
    QueuePollInterval = TimeSpan.FromMinutes(10) 
};

Although the jobs are "fire and forget" i dont want to wait 10 minutes, i want to process the queue right now. How to do this?

Upvotes: 1

Views: 1476

Answers (1)

Steve Land
Steve Land

Reputation: 4862

I'm assuming you mean that you want to keep your code as is (with the 10 minute PollingInterval) but need a mechanism to force jobs to run immediately when required - in which case I think you should be able to use the Hangfire Dashboard UI, where you can see a detailed breakdown of all jobs, as well as retry/trigger now etc.

To install it, just add the Nuget package: Hangfire.Dashboard.Authorization

and then add the config appropriate to your app type from the following link - it normally just works. http://docs.hangfire.io/en/latest/configuration/using-dashboard.html

Update - WinForms

For a WinForms project, I think your best option is still the Dashboard (which you can host in an OWIN server hosted on your localhost from within your application - its easier than you might think)

Here are a few references:

Upvotes: 3

Related Questions