I am trying to retrieve the enqueued jobs in Hangfire, using the following code:
IMonitoringApi monitor = JobStorage.Current.GetMonitoringApi();
var jobData = monitor.EnqueuedJobs(?, 0, 1);
The api says the first parameter is a string, (string queue). My question is, what does that string queue indicate and how do I get that? Thanks
Its the name of the Queue where you have put the job as you can make as many as queue in the Hangfire.
var options = new BackgroundJobServerOptions
{
Queues = new[] { "critical", "default" }
};
app.UseHangfireServer(options);
Here there are two queues one is critical and second one is default
so here you will pass default if you have not created any queues as default queue is the one which is default queue.
Implement the function as
public JobList<EnqueuedJobDto> EnqueuedJobs(string queue, int @from, int perPage)
{
return UseConnection(connection =>
{
var queueApi = GetQueueApi(connection, queue);
var enqueuedJobIds = queueApi.GetEnqueuedJobIds(queue, from, perPage);
return EnqueuedJobs(connection, enqueuedJobIds);
});
}
Link for implementation here https://searchcode.com/codesearch/raw/97584324/
Let me know if you accomplish it.