简体   繁体   English

来自MassTransit / RabbitMQ中负载均衡应用程序的竞争消费者

[英]Competing Consumers from load balancing application in MassTransit/RabbitMQ

I have just finished creating an API where the requests from the API are forwarded to a back-end service via MassTransit/RabbitMQ using the Request/Response pattern. 我刚刚创建了一个API,其中来自API的请求通过MassTransit / RabbitMQ使用请求/响应模式转发到后端服务。 We are now looking at pushing this into production, and are wanting to have multiple instances of the application (both API and service) running on different services, with a load balancer distributing the requests between them. 我们现在正在考虑将其推向生产阶段,并希望在不同的服务上运行多个应用程序实例(包括API和服务),负载均衡器在它们之间分配请求。

This leaves us in a position where we could potentially lose all of the messages if one of the servers is taken out of the pool for any reason. 这使我们处于一个位置,如果其中一个服务器由于任何原因从池中取出,我们可能会丢失所有消息。 I am looking at creating a RabbitMQ cluster between the servers (each server has a local install) and was wondering how I would go about setting up the competing consumers in this instance. 我正在考虑在服务器之间创建一个RabbitMQ集群(每个服务器都有本地安装),并且想知道如何在这个实例中设置竞争消费者。

Does RabbitMQ or MassTransit handle this so that only one consumer will receive the request, or will all consumers receive it and attempt to respond? RabbitMQ或MassTransit是否处理此问题,以便只有一个消费者会收到请求,或者所有消费者都会收到请求并尝试响应? Also, with the RabbitMQ cluster, how will MassTransit/RabbitMQ handle a node failing? 另外,使用RabbitMQ集群,MassTransit / RabbitMQ如何处理节点失败?

You should take a look at this document. 你应该看看这个文件。 http://www.rabbitmq.com/distributed.html http://www.rabbitmq.com/distributed.html

Explains the common distributed scenarios quite nicely. 非常好地解释了常见的分布式场景。 For your scenario I think federation would be a better fit than clustering. 对于您的场景,我认为联合比群集更合适。 If you go for clustering you should look at mirrored queues. 如果要进行群集,则应查看镜像队列。

If all you need is performance you are better of getting a single server to handle your message queuing and the other server will connect to it and produce/consume messages. 如果您只需要性能,那么您最好使用单个服务器来处理消息队列,而另一个服务器将连接到它并生成/使用消息。

I don't know how Mass Transit works but, if Request/Response is used you should get a single delivery of message to a single consumer, if the message is not ack-ed (the consumer crashes) an other consumer should pick it up. 我不知道公共交通是如何运作的,但是,如果使用请求/响应,您应该向单个消费者发送一条消息,如果消息没有被消息(消费者崩溃),另一个消费者应该接收它。

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

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