RabbitMQ 消息到多个队列分配公平
RabbitMQ message to multiple queues distribution equility
我正在使用 RabbitMQ 将消息从服务器分发到多个客户端。每个客户端都有自己的队列。服务器向交换器发布了一条消息,并且存在多个绑定导致分发到多个队列。
见下图。一条消息发布到 "Common Exchange",从中绑定到用户特定的交换(例如 "User 1 Exchange"),最后还有从用户特定的交换到用户队列的最后绑定(例如 "User 1 queue")。
现在我的问题是 我不希望某些客户端比其他客户端更早收到消息。(例如,用户 1 将始终有可用的消息早于用户 2)
我的问题是:消息是否按确定顺序在队列中可用?
编辑: 我知道差异可能非常小(如果有的话)。但我需要知道——客户在问。
服务器在高峰期会产生大量的大消息(每秒数千条)。同样由于可靠性,我们对几乎所有队列都有 HA 策略,这也可能会占用一些开销。所以我认为如果在峰值期间存在一些差异,它们最终会显示出来。
谢谢
弗兰克
我问了 same question on RabbitMQ forum 答案如下:
Message routing will first compile a list of exchanges for routing according to the bindings available,
then iterate over them. It works the same for queues.
Then channel that performs routing will simply iterate over the queues and publish a message
to them. This happens asynchronously, so a message for the first queue on the list can reach
the queue earlier or later than, say, the last queue on the list.
Consumer delivery with N queues also will happen asynchronously and (if enough cores are available
to the runtime) in parallel.
所以要回答问题:没有可预测的顺序其中一个特定的消息在队列中可用.
我正在使用 RabbitMQ 将消息从服务器分发到多个客户端。每个客户端都有自己的队列。服务器向交换器发布了一条消息,并且存在多个绑定导致分发到多个队列。
见下图。一条消息发布到 "Common Exchange",从中绑定到用户特定的交换(例如 "User 1 Exchange"),最后还有从用户特定的交换到用户队列的最后绑定(例如 "User 1 queue")。
现在我的问题是 我不希望某些客户端比其他客户端更早收到消息。(例如,用户 1 将始终有可用的消息早于用户 2)
我的问题是:消息是否按确定顺序在队列中可用?
编辑: 我知道差异可能非常小(如果有的话)。但我需要知道——客户在问。 服务器在高峰期会产生大量的大消息(每秒数千条)。同样由于可靠性,我们对几乎所有队列都有 HA 策略,这也可能会占用一些开销。所以我认为如果在峰值期间存在一些差异,它们最终会显示出来。
谢谢
弗兰克
我问了 same question on RabbitMQ forum 答案如下:
Message routing will first compile a list of exchanges for routing according to the bindings available, then iterate over them. It works the same for queues.
Then channel that performs routing will simply iterate over the queues and publish a message to them. This happens asynchronously, so a message for the first queue on the list can reach the queue earlier or later than, say, the last queue on the list.
Consumer delivery with N queues also will happen asynchronously and (if enough cores are available to the runtime) in parallel.
所以要回答问题:没有可预测的顺序其中一个特定的消息在队列中可用.