Run one task per queue

Tags: #<Tag:0x00007efd240ea2e0>

Good morning, let’s say I have three queues to perform tasks, currently tasks are performed in order of entry.

What I want: For the hangfire to perform one task per queue, example:

Row 1: Three tasks

Row 2: Two tasks

Row 3: Four tasks

I want Hangfire to run the first task in queue 1, after the first task in queue 2, and after the third queue and so on.

It is possible?

Not sure, what your user caseis. the task in hangfire are background task. You can treat each task is a queue. Hangfire use enqueue, it doesn’t means, task will be enqueue one after another, then dequeue one after another, there are background tasks and will run the same time.

Like @Haiyan_Du said, you probably want to do a bit of reading to understand the role of queues and background jobs as they are separate concepts that seem a bit muddled in your question.

If you want to run Background Job A and then Background Job B and ensure they run in that order, just enqueue Background Job B at the end of the execution of Background Job A. Alternatively, you can also buy a Hangfire.Pro license and use batching.