Artemis 联邦优先级调整如何工作?

How does Artemis federation priority-adjustment work?

根据the document,优先级调整意味着

when a consumer attaches its priority is used to make the upstream consumer, but with an adjustment by default -1, so that local consumers get load balanced first over remote, this enables this to be configurable should it be wanted/needed.

因此,优先级调整可以控制数据流向。当priority adjustment = -1时,broker会先将数据传输到远端,而不是本地使用。

Migrating between two clusters. Consumers and publishers can be moved in any order and the messages won't be duplicated (which is the case if you do exchange federation). Instead, messages are transferred to the new cluster when your consumers are there. Here for such a migration with blue/green or canary moving a number of consumers on the same queue, you may want to set the priority-adjustment to 0, or even a positive value, so message would actively flow to the federated queue.

这是否意味着当优先级调整为大于等于0的整数时,一旦远程消费者被生成,broker将更愿意将消息传递给远程消费者而不是本地消费者?如果在两个聚类条件下优先级为负会怎样? 我也看到一些样本将优先级调整为-1/0以外的值,我不知道这个值是如何工作的。 我还找到了一些关于ActiveMQ message priority setting的文档,似乎不适用于Artemis。 请告诉我更多关于参数“priority-adjustment”的含义的详细信息。

ActiveMQ Artemis 从上游队列中检索消息,以满足连接到联合队列的本地消费者对消息的需求。 为了从上游队列中检索消息,它使用本地消费者的优先级创建了一个远程消费者,该本地消费者的优先级调整值 adjustedPriority = consumer.getPriority() + priorityAdjustment.

远程消费者调整后的优先级与附加到上游队列的本地消费者的 consumer priority 相同。只有当高优先级消费者没有信用可用于消费消息,或者那些高优先级消费者拒绝接受消息时,消息才会发送给低优先级消费者。

如果所有消费者(上游和下游)都具有相同的优先级。当优先级调整 = -1.

时,本地消费者应首先接收消息,然后是远程消费者