【问题标题】:What could prevent NServiceBus from moving messages to the error queue if there are exceptions when processing?如果处理时出现异常,什么可以阻止 NServiceBus 将消息移动到错误队列?
【发布时间】:2010-11-30 02:40:16
【问题描述】:

我有一个使用 NServiceBus 处理消息的应用程序,在调试时我发现可能会抛出异常,并且消息会丢失。我检查了主队列和错误队列,并且只尝试了一次消息。

是否有任何常见的陷阱可能导致这种情况发生?

我在 Windows 7 64 位上使用 NServiceBus 2.0.0.1219 (2.0 RTM)。在旧版本上存在相同问题的其他问题: What could prevent NServiceBus from moving messages to the error queue if there are exceptions when processing?

网站总线。向命令处理程序端点发送命令。

网站配置文件:

<MsmqTransportConfig InputQueue="WebAppTest_InputQueue" ErrorQueue="ErrorQueue" NumberOfWorkerThreads="1" MaxRetries="5"/>

<UnicastBusConfig ForwardReceivedMessagesTo="AuditQueue">
  <MessageEndpointMappings>
    <add Messages="ABC.ServiceBus.Commands" Endpoint="CommandProcessor_InputQueue"/>
  </MessageEndpointMappings>
</UnicastBusConfig>

<DBSubscriptionStorageConfig>
  ...
</DBSubscriptionStorageConfig>

命令处理程序配置文件:

<MsmqTransportConfig InputQueue="CommandProcessor_InputQueue" ErrorQueue="ErrorQueue" NumberOfWorkerThreads="1" MaxRetries="5" />

<UnicastBusConfig ForwardReceivedMessagesTo="AuditQueue">
  <MessageEndpointMappings>
    <add Messages="ABC.ServiceBus.Commands" Endpoint="WebAppTest_InputQueue"/>
  </MessageEndpointMappings>
</UnicastBusConfig>

<DBSubscriptionStorageConfig>
  ...
</DBSubscriptionStorageConfig>

【问题讨论】:

  • 你能包括你的管理配置吗?还要确保为 NSB 正确安装了 MSMQ/DTC。您可以使用下载中的 Runner 工具确认这一点(tools\MsmqUtils)。
  • MSMQ/DTC 已正确安装,谢谢您的提示。我在问题中添加了相关的配置文件部分。
  • 我想知道它是否与消息转发有关。如果您删除“ForwardReceivedMessagesTo”,它仍然会发生吗?在此期间,我将尝试设置重现。
  • 后续,如果我添加了 ForwardReceivedMessagesTo,我不会丢失错误消息,但是我在审计队列中什么都没有。
  • 我删除了“ForwardReceivedMessagesTo”并发生相同的行为:消息被尝试一次,记录器记录异常(在命令处理程序中抛出),并且错误队列保持为空。

标签: exception msmq nservicebus


【解决方案1】:

由于消息转发与消息接收属于同一事务,如果接收失败,则转发失败。我在想,如果抛出异常,您可能希望它进入错误队列而不是审计队列,因为它没有被正确接收。如果您想查看流经的一切,日记可能是更好的选择。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-25
    • 1970-01-01
    • 2012-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多