We left Russia. We are against aggression and war with Ukraine. It is a tragedy for our nations, it is a nightmare

A problem with Multiple queues processing

Hi!

I’m doing the first tests with this incredible framework and I have encountered the following problem.

The queues do not work me, I have two queues (critical and default) and always performed the same queue.

It’s an empty MVC app. Any suggestions?

Owin startup class

            app.UseHangfire(config =>
        {
            config.UseSqlServerStorage("DemoContext");
            config.UseServer(queues: new[] { "critical", "default" });
        });

Controller

 public class HomeController : Controller
{
    public ActionResult Index()
    {
        WriteLine2("A message (default)");
        WriteLine("A message (critical)");
        return View();
    }

    [Queue("critical")]
    private static void WriteLine(string text)
    {
        BackgroundJob.Enqueue(() => Console.WriteLine(text));
    }

    private static void WriteLine2(string text)
    {
        BackgroundJob.Enqueue(() => Console.WriteLine(text));
    }
}

Sorry, I fixed the problem. It was a mistake because it did not understand how to do the job.

Startup owin class

            app.UseHangfire(config =>
        {
            //https://github.com/phenixdotnet/Hangfire.Unity
            var container = UnityConfig.GetConfiguredContainer() as UnityContainer;
            config.UseUnityActivator(container);

            config.UseSqlServerStorage("DemoContext");
            config.UseServer(queues: new[] { "critical", "default" });
        });

Controller

        public ActionResult Index()
    {
        BackgroundJob.Enqueue(() => _utilities.DoSomething(String.Empty));
        BackgroundJob.Enqueue(() => _utilities.DoSomethingElse(String.Empty));
        return View();
    }

Funcs to Queue

public interface IUtilities
{
    void DoSomething(string text);
    void DoSomethingElse(string text);
}

public class Utilities : IUtilities
{
    [Queue("critical")]
    public void DoSomething(string text)
    {
        Console.WriteLine(String.Format("DoSomething - {0}", text));
    }

    public void DoSomethingElse(string text)
    {
        System.Threading.Thread.Sleep(5000);
        Console.WriteLine(String.Format("DoSomethingElse - {0}", text));
    }
}

Close the post.
Thanks.