Is there a way, to plug in own logic to pick tasks from queues?
There is a Hangfire server,configured to use sql:
var serverOptions = new BackgroundJobServerOptions
{
WorkerCount = 1,
Queues= new string[]{"high-priority",
"normal-priority-long-running",
"normal-priority-very-long-running"}
};
Users upload files to be processed on the server. some files have 10 rows, some 20,000 rows,which take from 10" to 20’ to process.
Here is what I am trying to achieve:
the app logic will decide which queue to add jobs to. Then I want to inject my own logic to Hangfire, so it picks the next job from a queue as follows, in as simplifies manner:
{
If there is any jobs in the "high-priority" pick and run.
If there is a job in ,"normal-priority-long-running", pick and run.
If there is any jobs in the "high-priority" pick and run.
If there is a job in "normal-priority-very-long-running", pick and run
}
repeat.
Is this possible with current version of Hangfire?
For my case it works if I could pass a function at startup to Hangfire Config accepting some parameters about the queues and task picking.
Will be happy to contribute code if needed.
Thanks for the great work.