如何使用 MessageQueue 检测连接中断

发布于 2024-09-02 03:05:48 字数 202 浏览 3 评论 0原文

我用 C# 编写的应用程序使用 .NET 中的 MessageQueue 类与另一个远程应用程序通信消息,并且在所有情况下 MessageQueue 应始终与远程消息队列“连接”(存在心跳)。如果它没有“连接”,则表明出现了问题,我的应用程序将需要执行一些操作,例如更新事件日志。

MessageQueue 类中是否有方法可用于检测此类连接中断?

My application written in C# makes use of the MessageQueue class in .NET for communicating messages with another remote application and the MessageQueue should always be "connected" (heartbeat present) with the remote messageQueue under all circumstances. If it is not "connected", then it signals that something is wrong and my application will need to perform some actions such as updating an event log.

Is there a method in the MessageQueue class that can be used to detecting such breaks in connection?

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

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

发布评论

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

评论(1

猫卆 2024-09-09 03:05:48

消息队列在很大程度上是为了防止断开连接而设计的。并且支持通过多台机器进行路由。因此,它无法检查是否存在实时连接。如果这是一个要求,您可能不应该考虑 MSMQ,TCP 将是一个更好的老鼠陷阱。

您可以考虑请求确认消息和超时。虽然那是被动的。心跳是可能的,但请务必使用单独的非事务性队列。

Message queuing is very much designed to survive disconnects. And supports routing through several machines. As such, it doesn't have a way to check if a live connection is present. You probably shouldn't consider MSMQ if that's a requirement, TCP would be a better mouse trap.

You could consider asking for acknowledgment of your message and time-out on that. That's passive though. A heart beat is possible, but be sure to use a separate, non transactional queue.

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