I have Hangfire running as a service and using MSMQ to read from a remote public queue. When I enqueue a job my service throws the following error:
2015-06-08 19:21:10.2678;Info;Hangfire.Server.Worker;Error occurred during execution of ‘Worker #17’ component. Execution will be retried (attempt 2 of 2147483647) in 00:00:04 seconds.;“System.Messaging.MessageQueueException (0x80004005): The transaction operations sequence is invalid.
at System.Messaging.MessageQueue.ReceiveCurrent(TimeSpan timeout, Int32 action, CursorHandle cursor, MessagePropertyFilter filter, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
at System.Messaging.MessageQueue.Receive(TimeSpan timeout, MessageQueueTransaction transaction)
at Hangfire.SqlServer.Msmq.MsmqJobQueue.Dequeue(String queues, CancellationToken cancellationToken)
at Hangfire.Server.Worker.Execute(CancellationToken cancellationToken)
at Hangfire.Server.AutomaticRetryServerComponentWrapper.ExecuteWithAutomaticRetry(CancellationToken cancellationToken)”
Searching for this error I found a few sites saying the receive should be using a TransactionScope instead of a MessageQueueTransaction (https://johonline.wordpress.com/2012/07/24/msmq-transactional-remote-receive/)
Is this a problem with the MSMQ dequeue code here https://github.com/HangfireIO/Hangfire/blob/master/src/Hangfire.SqlServer.Msmq/MsmqJobQueue.cs
Or am I missing something that I should have set up differently to get this to work?