简体   繁体   English

像RabbitMQ这样的消息队列是否是此应用程序的理想解决方案?

[英]Is a message queue like RabbitMQ the ideal solution for this application?

I have been working on a project that is basically an e-commerce. 我一直在从事一个基本上是电子商务的项目。 It's a multi tenant application in which every client has its own domain and the website adjusts itself based on the clients' configuration. 它是一个多租户应用程序,其中每个客户端都有自己的域,网站会根据客户端的配置进行调整。

If the client already has a software that manages his inventory like an ERP, I would need a medium on which, when the e-commerce generates an order, external applications like the ERP can be notified that this has happened to take actions in response. 如果客户已经拥有像ERP这样的可管理其库存的软件,那么我将需要一种媒介,当电子商务生成订单时,可以在该媒介上通知外部应用程序(例如ERP)已经采取了相应措施。 It would be like raising events over different applications. 这就像在不同的应用程序上引发事件一样。

I thought about storing these events in a database and having the client make requests in a short interval to fetch the data, but something about polling and using a REST Api for this seems hackish. 我曾考虑过将这些事件存储在数据库中,并让客户端在很短的间隔内发出请求以获取数据,但是有关轮询和为此使用REST Api的某些东西似乎有些黑。

Then I thought about using Websockets, but if the client is offline for some reason when the event is generated, the delivery cannot be assured. 然后我考虑使用Websockets,但是如果生成事件时客户端由于某种原因脱机,则无法保证交付。 Then I encountered Message Queues, RabbitMQ to be specific. 然后我遇到了Message Queues,RabbitMQ是具体的。 With a message queue, modeling the problem in a simplistic manner, the e-commerce would produce events on one end and push them to a queue that a clients worker would be processing as events arrive. 使用消息队列以一种简单的方式对问题进行建模,电子商务将在一端生成事件,并将其推送到事件发生时客户工作人员将要处理的队列。

I don't know what is the best approach, to be honest, and would love some of you experienced developers give me a hand with this. 老实说,我不知道什么是最好的方法,并且希望您中的一些经验丰富的开发人员可以帮助我。

Your idea of using a message queue is a good one, better than database or websockets for the reasons you describe. 由于您描述的原因,使用消息队列的想法是一个好主意,比数据库或Websocket更好。 With the message queue (RabbitMQ, or another server/broker based system such as Apache Qpid) approach you should consider putting a broker in a "DMZ" sort of network location so that your internal ecommerce system can push events out to it, and your external clients can reach into without risking direct access to your core business systems. 使用消息队列(RabbitMQ或其他基于服务器/代理的系统,例如Apache Qpid)的方法,您应该考虑将代理放置在“ DMZ”类型的网络位置,以便您的内部电子商务系统可以将事件推送给它,并且您的外部客户可以接触而不会冒险直接访问您的核心业务系统。 You could also run a separate broker per client. 您还可以为每个客户端运行一个单独的代理。

I do agree with Steve, using a message queue in your situation is ideal. 我同意史蒂夫的观点,在您的情况下使用消息队列是理想的选择。 Message queueing allows web servers to respond to requests quickly, instead of being forced to perform resource-heavy procedures on the spot. 消息队列使Web服务器可以快速响应请求,而不必被迫现场执行大量资源的过程。 You can put your events to the queue and let the consumer/worker handle the request when the consumer has time to handle the request. 您可以将事件放入队列,并在使用者有时间处理请求时让使用者/工作人员处理请求。

I recommend CloudAMQP for RabbitMQ, it's easy to try out and you can get started quickly. 我建议将CloudAMQP用于RabbitMQ,尝试起来很容易,您可以快速上手。 CloudAMQP is a hosted RabbitMQ service in the cloud. CloudAMQP是云中托管的RabbitMQ服务。 I also recommend this RabbitMQ guide: https://www.cloudamqp.com/blog/2015-05-18-part1-rabbitmq-for-beginners-what-is-rabbitmq.html 我也推荐此RabbitMQ指南: https : //www.cloudamqp.com/blog/2015-05-18-part1-rabbitmq-for-beginners-what-is-rabbitmq.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM