0MQ 是一个协议、一个层,还是两者兼而有之?我可以将它与 STOMP 结合使用吗?

发布于 2024-09-09 10:57:43 字数 635 浏览 4 评论 0原文

作为 STOMP 和 0MQ 的新手,我已经陷入了困境,但简而言之,我希望通过与一个 PHP MOM 或多个 PHP MOM 的交互来促进浏览器中客户端到客户端的通信。我正在考虑使用 WebSocket 在 html5 浏览器客户端和 MOM 端点之间提供持久双工连接(如果可用),然后使用这些端点来促进任意数量的浏览器客户端之间的通信,这可能与 1-1、1- 相关。许多,多对一的关系。

MOM 端点可能出于不同目的与其他服务器或它们之间进行通信,我相信 0MQ 可能是在这些服务器之间快速交换信息的可行方法。作为客户端之间的消息传递协议,STOMP 看起来不错(尽管我知道协议定义存在一些问题)......

所以这是我的困惑点。要使用 STOMP,MOM 必须是 STOMP 代理,如果它是 STOMP 代理,那么由于 0MQ 是“无代理”消息传递层,我是否会违背使用两者的目的?

为了澄清,我正在考虑使用 0MQ 进行 MOM - MOM 通信,使用 STOMP 进行客户端 - 客户端通信。

当然,除非有一种方法可以重新利用 0MQ 来促进客户端到客户端的通信?我想我真正的困惑在于 0MQ——它是一个轻量级消息传递层,而不是一个协议,还是两者兼而有之?如果它只是一个层,我不能使用0MQ来传输STOMP消息吗?

如果有人能为我阐明 0MQ,我将非常感激 - 谢谢!

I've tied myself in knots, being new to both STOMP and 0MQ, but in a nutshell, I want to facilitate client to client communication in the browser with interaction from a PHP MOM or a number of PHP MOMs. I'm considering using WebSocket to provide persistent duplex connections (when available) between html5 browser clients and the MOM endpoints, and then use those endpoints to facilitate communication between any number of browser clients, which may be related by 1-1, 1-many, many-1 relationships.

The MOM endpoints may communicate with other servers, or amongst themselves, for different purposes, and I believe that 0MQ may be a viable way to exchange information quickly between these servers. As a protocol for messaging between clients, STOMP looks good (though I'm aware of some problems with the protocols definition)....

.... so here's my point of confusion. To use STOMP, the MOM would have to be a STOMP broker, and if its a STOMP broker, then as 0MQ is a 'brokerless' messaging layer, wouldn't I be defeating the purpose of using both?

To clarify, I'm considering 0MQ for MOM - MOM communication, and STOMP for client - client communication.

Unless of course, there is a way in which I could repurpose 0MQ to facilitate client to client communications? I guess my real confusion is with 0MQ- is it a light weight messaging layer, and not a protocol, or both? If its a layer only, couldn't I use 0MQ to transport STOMP messages?

If anyone could shine some light on 0MQ for me, I'd be very grateful- thanks!

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

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

发布评论

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

评论(1

病毒体 2024-09-16 10:57:43

0MQ 提供了一个无服务器的类似套接字的 API,您可以在其上覆盖您自己的协议。 0MQ 传输纯未解释的二进制数据(尽管某些语言绑定添加了对特定序列化的支持,例如 python pickling 或 JSON)。

与普通套接字不同,0MQ套接字可以是多对一、一对多。

0MQ 还具有消息传递模式的概念 - 例如,您可以定义 REQ/REP 套接字,它强制执行每个请求后面必须有响应的约束 - 您不允许连续发送两个请求。还有各种其他模式以适应不同的情况。

请参阅 0MQ 指南API

因此,回答您的一些问题 - 0MQ 基本上是一个消息传递层,原则上您应该能够通过 0MQ 套接字发送 STOMP,就像普通网络套接字一样。但是,我不确定 Web 客户端是否可以直接使用 0MQ - 它需要语言绑定并且 ZMQ 本机库需要可用。我认为这排除了网络客户端的使用。

0MQ provides a server-less socket-like API, over which you can overlay your own protocols. 0MQ transports plain uninterpreted binary data (though some of the language bindings add support for specific serialisations like python pickling or JSON).

Unlike normal sockets, 0MQ sockets can be many-to-one, one-to-many.

0MQ also has the notion of messaging patterns - for example, you can define REQ/REP sockets, which enforce the constraint that each request must be followed by a response - you are not permitted to send two requests in a row. There are various other patterns to suit different situations.

See the 0MQ Guide and API

So to answer some of your question - 0MQ is basically a messaging layer, and in principle you should be able to send STOMP over 0MQ sockets just as for normal network sockets. However, I'm not sure that a web client can use 0MQ directly - it needs language bindings and the ZMQ native libraries need to be available. I think this rules it out for web client usage.

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