3

我们在生产中使用 NServiceBus,在我们的日志文件中我们看到以下错误:

ERROR Our.Namespace.SomeMessageHandler [(null)] <(null)> - MethodName  --> end with exception: NServiceBus.Unicast.Queuing.FailedToSendMessageException: Failed to send message to address: our.namespace.worker@somemachinename ---> System.Messaging.MessageQueueException: Cannot enlist the transaction.
    at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType)
    at NServiceBus.Unicast.Queuing.Msmq.MsmqMessageSender.NServiceBus.Unicast.Queuing.ISendMessages.Send(TransportMessage message, Address address)
    --- End of inner exception stack trace ---
    at NServiceBus.Unicast.Queuing.Msmq.MsmqMessageSender.ThrowFailedToSendException(Address address, Exception ex)
    at NServiceBus.Unicast.Queuing.Msmq.MsmqMessageSender.NServiceBus.Unicast.Queuing.ISendMessages.Send(TransportMessage message, Address address)
    at NServiceBus.Unicast.UnicastBus.SendMessage(List`1 addresses, String correlationId, MessageIntentEnum messageIntent, Object[] messages)
    at NServiceBus.Unicast.UnicastBus.SendMessage(Address address, String correlationId, MessageIntentEnum messageIntent, Object[] messages)
    at NServiceBus.Unicast.UnicastBus.NServiceBus.IBus.Send(Address address, Object[] messages)
    at Our.Namespace.SomeMessageHandler.MethodName(EventLogVO eventLog, IApplicationContext applContext, CreateEventLogHistory message)

目标机器上的队列存在(双重检查)。这里奇怪的是,它不会一直发生并且对于发送到该队列的每条消息,而是偶尔发生(这意味着有消息到达该队列)。

搜索了一下,没有找到类似的案例。

我在这里想念什么?

4

2 回答 2

3

我们最近遇到了这个错误,并将其追踪为以下错误之一:

  • 数据库性能。我们调整了一个长时间运行的查询,但问题仍然存在。
  • 交易范围大。您可能正在做一些会导致过多资源管理器参与的事情。
  • MSMQ 资源。最终,我们的磁盘速度不够快,无法执行我们使用 MSMQ 执行的操作所需的 IO。

我会尝试追查真正的来源(希望你能从上面得到一些想法)。但如果一切都失败了,首先打开 System.Transactions 日志,看看它是否真的超时。如果是,则在 app.config 中使用此部分

于 2014-09-29T22:52:41.620 回答
1

我在一个处理程序中发生了这种情况,该处理程序需要一分钟多的时间才能完成,我最终通过将其添加到 app.config 来增加超时

<system.transactions>
  <defaultSettings timeout="00:05:00"/>
</system.transactions>

按照这个: https ://erictummers.wordpress.com/2014/05/28/cannot-enlist-the-transaction/

此外,我根据这篇文章更改了机器配置:http: //blogs.msdn.com/b/ajit/archive/2008/06/18/override-the-system-transactions-default-timeout-of-10-minutes -in-the-code.aspx

我还写了一个编辑 machine.configs 的快速应用程序: https ://github.com/hfortegcmlp/MachineConfigEditor

于 2014-12-30T15:09:05.933 回答