【问题标题】:NServiceBus - message not always delivers and causing exception Cannot enlist the transactionNServiceBus - 消息并不总是传递并导致异常无法登记事务
【发布时间】:2014-11-22 20:53:00
【问题描述】:

我们在生产环境中使用 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)

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

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

我在这里错过了什么?

【问题讨论】:

  • 根据您的其他问题,我猜您的交易正在超时。如果没有,我建议您显示一些代码并描述失败的消息在做什么。

标签: msmq nservicebus nservicebus3


【解决方案1】:

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

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

我会尝试追查真正的来源(希望您从上面得到一些想法)。但是,如果所有其他方法都失败了,请先打开 System.Transactions 日志记录以查看它是否真的超时。如果是,则在 app.config 中使用this section

【讨论】:

  • MSMQ 配额超出 +1(您可能想增加它),还要检查您的事务死信队列并清除它
【解决方案2】:

我在一个处理程序中发生了这种情况,需要一分钟多的时间才能完成, 我最终通过将其添加到 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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-14
    • 1970-01-01
    • 1970-01-01
    • 2022-08-10
    相关资源
    最近更新 更多