RabbitMQ 和消息优先级 [英] RabbitMQ and message priority

查看:112
本文介绍了RabbitMQ 和消息优先级的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

RabbitMQ 有消息优先级的概念吗?我有一个问题是一些更重要的消息由于不太重要的消息排在队列中而被减慢.我希望高优先级的人优先并移到队列的前面.

Does RabbitMQ have any concept of message priority? I have an issue were some more important messages are being slowed down due to less important messages sitting before it in the queue. I would love the high-priority ones to take precedence and move to the front of the queue.

我知道我可以使用快速"队列和慢速"队列这两个队列来近似这个,但这似乎是一个黑客.

I know I can approximate this using two queues a "fast" queue and a "slow" queue, but that seems like a hack.

有谁知道使用 RabbitMQ 的更好解决方案吗?

Does anyone know of a better solution using RabbitMQ?

推荐答案

关于这个问题的答案已经过时.从 RabbitMQ 3.5.0 开始,现在有对 AMQP 标准每消息优先级的核心支持.文档 包含所有血腥细节,但简而言之:

The answers on this question are out-of-date. As of RabbitMQ 3.5.0, there is now in-core support for AMQP standard per-message priorities. The documentation has all the gory details, but in short:

  • 您需要在创建队列时定义队列的优先级范围;
  • 没有设置优先级的消息的优先级为 0;
  • 数字优先级高于队列中设置的最大值的消息将获得队列支持的最高优先级.

文档中有更多有趣的警告.非常值得一读.

More interesting caveats are in the docs. It's well worth reading them.

这篇关于RabbitMQ 和消息优先级的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆