我希望我的 Rails 应用能够监听和发布 STOMP 消息。
This article给出了如何使用 ruby STOMP 客户端以及将该客户端集成到 Rails 应用程序中的 gem activemessaging
的示例。那里的功能似乎很理想,但是 activemessaging
gem 似乎不再被维护。
有人知道我可以使用一个 gem 来实现与 activemessaging
gem 类似的功能吗?我找不到,所以失败了:
我如何在 Rails 应用程序的上下文中使用持久连接来初始化 Stomp 客户端,这样 1) 客户端的生命周期与运行我的应用程序的 ruby 进程的生命周期相关联,而不是与请求响应过程相关联, 2) 我可以使用 Active Record 模型或应用程序中定义的服务对象等代码来使用消息吗?
最佳答案
根据ActiveMessaging project website :
ActiveMessaging is a generic framework to ease using messaging, but is not tied to any particular messaging system - in fact, it now has support for Stomp, AMQP, beanstalk, Amazon Simple Queue Service (SQS), JMS (using StompConnect or direct on JRuby), WebSphere MQ...
因此,它是一个简化各种消息传递协议(protocol)和/或提供商之间集成的接口(interface)。但是,由于您使用标准化消息传递协议(protocol)(即 STOMP)您并不真正需要它。
我建议您只需使用 this STOMP gem原始文章中引用了该内容。
STOMP,顾名思义,是一个非常简单的协议(protocol)。您应该能够在应用程序中根据需要使用它。
关于ruby-on-rails - 使用 STOMP 进行 Rails 发布/订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60837987/