如果处理时出现异常,什么会阻止 NServiceBus 将消息移至错误队列?

发布于 2024-10-04 03:23:06 字数 1379 浏览 0 评论 0原文

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

是否存在可能导致这种情况发生的常见陷阱?

我在 Windows 7 64 位上使用 NServiceBus 2.0.0.1219 (2.0 RTM)。旧版本上有相同问题的其他问题: 如果处理时出现异常,什么会阻止 NServiceBus 将消息移动到错误队列?

网站 Bus.Send a command 到该命令处理程序端点。

网站配置文件:

<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>

I have an application using NServiceBus to process messages, and while debugging I'm finding that exceptions may be thrown, and the message is lost. I've checked both the main and error queues, and the message was only attempted once.

Are there any common pitfalls that could cause this to happen?

I use NServiceBus 2.0.0.1219 (2.0 RTM) on Windows 7 64 bit. Other question with same issue on older version:
What could prevent NServiceBus from moving messages to the error queue if there are exceptions when processing?

The website Bus.Send a command to the command handler endpoint.

Website Config File:

<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>

Command Handler Config File:

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

寻找我们的幸福 2024-10-11 03:23:06

由于消息转发与消息接收属于同一事务的一部分,因此如果接收失败,则转发也会失败。我在想,如果抛出异常,您可能希望它进入错误队列而不是审核队列,因为它没有被正确接收。如果你想无论如何都看到所​​发生的一切,写日记可能是更好的选择。

Since the message forwarding is part of the same transaction as the receipt of the message, if the receive fails, the forwarding fails. I'm thinking that if an exception is thrown you probably want it to go to the error queue and not the audit queue since it wasn't received correctly. If you want to see everything that flows through irregardless, journaling might be a better bet.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文