Send message from one application and process in other application in hangfire

hi everybody

looking for an example where one application is sending messages (MSMQ + SQL Server), and other application connected to same DB and MSMQ is processing these messages.

Any body who has done it before? or any idea how it work in Hangfire?

Who is Hangfire server in this case? Sender or Receiver?

I tried it to do with MVC and Console application but failed. MVC app is Enqueue message but it goes directly into SQL Server. although there is transnational MSMQ in between but nothing in there. here is code for MVC app

   public static void Configuration(IAppBuilder app)
    { 
        var options = new BackgroundJobServerOptions
        {
            Queues = new[] { "hangfire-critical", "hangfire-default" },
            ServerName = "MySERVERNAME"
        };
        var sqlServerOptions = new SqlServerStorageOptions
        {
            PrepareSchemaIfNecessary = true
        };
        /* This server will process only MSMQ queues, i.e. new jobs */
        GlobalConfiguration.Configuration.UseSqlServerStorage("HangfireDemoDb", sqlServerOptions).UseMsmqQueues(@".\\Private$\\", options.Queues);

        app.UseHangfireServer(options);
        app.UseHangfireDashboard();

        PrepareMessageQueue(options.Queues);
    }

    private static void PrepareMessageQueue(string[] queues)
    {
        foreach (var queue in queues)
        {
            string queueName = ".\\Private$\\" + queue;
            if (!MessageQueue.Exists(queueName))
            {
                MessageQueue myNewPrivateQueue = MessageQueue.Create(queueName,true);
                //myNewPrivateQueue.Send("New Message Queue created");
            }
        }
    }

also dashboard queue show me messages are in there but when i click on enqued message it throw error. “invalid queue path name”

What code i need in Console application to process messages?

Thanks in advance

1 Like

were you be able to implement this ?