HangfireIO / Hangfire

An easy way to perform background job processing in .NET and .NET Core applications. No Windows Service or separate process required
https://www.hangfire.io
Other
9.46k stars 1.71k forks source link

How to delete the queue from hangfire #2224

Open shashikant1729 opened 1 year ago

shashikant1729 commented 1 year ago

Hi all

Can someone help me to figure out how to delete the open queue in Hangfire? I am able to delete jobs so they don't continue queuing against dead queues, but I have not found a way to actually delete the queue itself, as they continue to clutter up the dashboard page.

I use the below code to delete all the jobs :

var monitoringApi = JobStorage.Current.GetMonitoringApi();
var queues = monitoringApi.Queues();
foreach (QueueWithTopEnqueuedJobsDto queue in queues)
{
      var jobList = monitoringApi.EnqueuedJobs(queue.Name, 0, int.MaxValue);
      foreach (var item in jobList)
      {
           BackgroundJob.Delete(item.Key);
      } 
}

I attached the image below : Annotation 2023-06-05 115132

Aside from manually deleting entries in the JobQueue table, is there a way to clean the queues ?

SpirosArk commented 7 months ago

@shashikant1729 did you managed to find a solution on this?