Configuring Hangfire SqlServer with MSMQ on windows application

msmq
Tags: #<Tag:0x00007f21e16cf048>

#1

Configuration
GlobalConfiguration.Configuration
.UseSqlServerStorage(GetConnectionStringBuilder().ConnectionString)
.UseMsmqQueues(@“FormatName:Direct=OS:localhost\hangfire-{0}”);
Starting Server
server = new BackgroundJobServer();
Queuing Job
var manager = new RecurringJobManager();
manager.AddOrUpdate(“Rec-Show-Message”,Job.FromExpression(() => ShowMessage()), Cron.Minutely());

Unable to see any queue created in MSMQ or Job getting executed. I have already configured DTC by following the link: [http://nthrbldyblg.blogspot.com/2017/02/msmq-between-two-computers.html]


#2

Added the following code before configuration and MSMQ started working.

var queuePath = @".\Private$";
var queueName = “YourQueueName”;
if (!MessageQueue.Exists(string.Format("{0}{1}", queuePath, queueName)))
{
var queue = MessageQueue.Create(string.Format("{0}{1}", queuePath, queueName), true);
queue.Label = “Your Queue Description”;
}