我在 Pivotal Cloud Foundry 中部署了一个 Spring Boot 应用程序。我有 4 个正在运行的应用程序实例。应用程序使用 RabbitMQ 队列中的消息并进行进一步处理。如果我在 RabbitMQ 中将队列的消费者数量设置为 40,那么这 40 个消费者是否会均匀分布在正在监听的应用程序中?
最佳答案
来自文档here :
By default, RabbitMQ will send each message to the next consumer, in sequence. On average every consumer will get the same number of messages. This way of distributing messages is called round-robin
为了回答您的问题,您的应用程序之间的负载将大致相等。
来自here的另一个有点支持的片段:
Direct exchanges are often used to distribute tasks between multiple workers (instances of the same application) in a round robin manner. When doing so, it is important to understand that, in AMQP 0-9-1, messages are load balanced between consumers and not between queues.
关于java - Rabbitmq 消费者,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42143536/