RabbitMQ 和 em-websocket
我正在努力弄清楚如何在rabbitmq和em-websocet之间进行通信。
我想将来自 Ruby on Rails 网页的消息放入队列中,并让队列处理程序处理该消息,即使浏览器关闭也是如此。如果浏览器保持打开状态,我希望队列处理程序的结果将 json 传递回浏览器。
我确实找到了 this 但 github 页面说它已被弃用。有人能指出我正确的方向吗?
I am struggling to work out how I can communicate between rabbitmq and em-websocet.
I want to place a message from a ruby on rails web page on a queue and have the queue handler process the message even if the browser is closed down. If the browser stays open, I want the results of the queue handler to pass json back to the browser.
I did find this but the github page says it is depreceated. Can anyone point me in the right direction?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,您有一个 RabbitMQ 队列,一种将项目添加到该队列的方法,一种处理添加到该队列的项目的方法,并且您基本上希望通知浏览器该队列的进度。
有两种主要方法可以解决此问题:
作为队列处理器的最终操作,通过消息总线将项目/消息发布到正在侦听该消息总线的 em-websocket 实例。
如果您可以向 RabbitMQ 添加功能,那么您可以从 RabbitMQ 内部进行发布,作为后处理挂钩或类似的东西。 (注意,我对 RabbitMQ 的了解还不够,所以不能说你绝对可以做到这一点)。
或者,使用 #1,您可以使用 Pusher.com 或类似的服务来卸载 WebSocket 连接的处理。然后,从队列处理器中,您可以对该服务的 API 进行发布调用。
在使用 Pusher 的情况下,如果您发布到不再存在(具有任何连接)的通道/套接字,则消息将被丢弃。
希望这有帮助。如果您在设置基本 em-websocket 服务器方面需要任何帮助,请告诉我。
From what I can gather, you've got a RabbitMQ queue, a way to add items to that queue, something to process items that get added to that queue, and you basically want to notify the browser of progress on that queue.
There are two main ways that you could approach this:
As the final action of the queue processor, publish the item/message via a messaging bus to an instance of em-websocket that's listening on that message bus.
If you can add features to RabbitMQ, then you could do the publish from within RabbitMQ, as a post-processed hook or something like that. (note, I don't know enough about RabbitMQ to say you can definitely do this).
Alternatively with #1, you could use Pusher.com or similar service to offload the handling of the WebSocket connections. Then, from within your queue processor, you would do the publish call to that services' API.
In the case of using Pusher, if you publish to a channel/socket that no longer exists (has any connections), then the message would just get discarded.
Hopefully this helps. Let me know if you want any help in setting up a basic em-websocket server.