如何在没有 MSMQ 的情况下通过 http 接收消息

发布于 2024-08-27 05:39:34 字数 417 浏览 4 评论 0原文

我需要一个可靠的消息传递框架,该框架通过 http/https 运行(由于客户端安全要求)并且不使用 MSMQ(因为某些客户端将使用 Windows XP Home)。客户端只需要能够接收消息,而不是发送消息。

我们已经在服务器上为每个用户建立了一个消息队列,并且接收者通过连接到服务器上的 HttpHandler 并从中获取 Stream 来获取消息。

WebResponse.GetResponseStream()

我们保持此流打开,并使用 Stream.Read( 从中获取消息) )。这大部分是有效的,但是 Stream.Read() 是一个阻塞调用,我们无法可靠地中断它。我们需要能够停止和启动接收器而不丢失消息,但旧流经常挂起,即使我们在其线程上调用 Thread.Abort 之后也是如此。

有什么建议吗?

I need a reliable messaging framework that runs over http/https (due to client security requirements) and that doesn't use MSMQ (because some clients will use Windows XP Home). The clients only need to be able to receive messages, not send them.

We already have a message queue on the server for each user, and the receivers have been getting messages by connecting to an HttpHandler on the server and getting a Stream from

WebResponse.GetResponseStream()

We keep this stream open, and pull messages off of it using Stream.Read(). This MOSTLY works, but Stream.Read() is a blocking call, and we can't reliably interrupt it. We need to be able to stop and start the receiver without losing messages, but the old stream often hangs around, even after we call Thread.Abort on its thread.

Any suggestions?

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

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

发布评论

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

评论(2

终难遇 2024-09-03 05:39:34

我会使用 WCF。它支持 WS-ReliableMessaging 标准。您可以对其进行配置,以便保证消息以正确的顺序到达。

I would use WCF. It supports the WS-ReliableMessaging standard. You can configure it so that messages are guaranteed to arrive, and in the correct order.

迷迭香的记忆 2024-09-03 05:39:34

关于锁定问题,你考虑过WCF框架吗?

单身的。一次一个线程可以访问服务对象。这是该属性的默认值。
可重入。一次一个线程可以访问服务对象,但该线程可以退出并重新进入。
多种的。一次可以有多个线程访问服务对象。

http://msdn.microsoft.com/en-us/library/dd936243。 aspx

它允许对服务在多个调用中的行为方式进行大量控制,并且可以与 http 和 https 一起使用。

About the locking problem, have you considered the WCF framework?

Single. One thread at a time can access the service object. This is the default value for this property.
Reentrant. One thread at a time can access the service object but the thread can exit and reenter.
Multiple. More than one thread at a time can access the service object.

http://msdn.microsoft.com/en-us/library/dd936243.aspx

It allows a lot of control on how the service behaves with multiple calls and works with both http and https.

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