Schedule works but Enqueue fails with msmq remote private queue

Tags: #<Tag:0x00007f065c4f6d70>

BackgroundJob.Enqueue throws this exception when using msmq remote private queue:

[InvalidOperationException:Message Queuing has not been installed on this computer.]

at System.Messaging.Interop.SafeNativeMethods.MQBeginTransaction(ITransaction& refTransaction)

at System.Messaging.MessageQueueTransaction.Begin()

at Hangfire.SqlServer.Msmq.MsmqJobQueue.Enqueue(IDbConnection connection,String queue,String jobId)

at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.<Commit>b__5_0(DbConnection connection)

at Hangfire.SqlServer.SqlServerStorage.<>c__DisplayClass19_0.<UseTransaction>b__0(DbConnection connection)

at Hangfire.SqlServer.SqlServerStorage.UseConnection[T](Func`2 func)

at Hangfire.SqlServer.SqlServerStorage.UseTransaction[T](Func`2 func,Nullable`1 isolationLevel)

at Hangfire.SqlServer.SqlServerStorage.UseTransaction(Action`1 action)

at Hangfire.SqlServer.SqlServerWriteOnlyTransaction.Commit()

at Hangfire.Client.CoreBackgroundJobFactory.Create(CreateContext context)

at Hangfire.Client.BackgroundJobFactory.<>c__DisplayClass7_0.<CreateWithFilters>b__0()

at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter,CreatingContext preContext,Func`1 continuation)

at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter,CreatingContext preContext,Func`1 continuation)

at Hangfire.Client.BackgroundJobFactory.InvokeClientFilter(IClientFilter filter,CreatingContext preContext,Func`1 continuation)

at Hangfire.Client.BackgroundJobFactory.Create(CreateContext context)

at Hangfire.BackgroundJobClient.Create(Job job,IState state)



[BackgroundJobClientException:Background job creation failed.See inner exception for details.]

at Hangfire.BackgroundJobClient.Create(Job job,IState state)

at SyncInvokeEnterPaymentForAccount(Object ,Object[] ,Object[] )

at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,Object[] inputs,Object[]& outputs)

at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance,Object[] inputs,Object[]& outputs)

BackgroundJob.Schedule with a TimeSpan of 0 works, but it’s not really a good workaround for me. Doing it that way takes about 30 seconds for the job to get enqueued on the server (even though the Latency reads just a few seconds).