如果处理时出现异常,什么会阻止 NServiceBus 将消息移至错误队列?
我有一个使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
由于消息转发与消息接收属于同一事务的一部分,因此如果接收失败,则转发也会失败。我在想,如果抛出异常,您可能希望它进入错误队列而不是审核队列,因为它没有被正确接收。如果你想无论如何都看到所发生的一切,写日记可能是更好的选择。
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.