【问题标题】:AMQPLIB - NodeJS - Asserting a Lazy Queue in RabbitMQAMQPLIB - NodeJS - 在 RabbitMQ 中断言一个惰性队列
【发布时间】:2018-11-23 05:11:49
【问题描述】:

我想使用 nodeJs 通过 amqplib assert a queue in lazy mode into existence

我知道我可以通过创建策略来做到这一点,我不想这样做,因为目前在我们拥有的环境中很难实现自动化。

我尝试了以下方法:

        let options = {
            durable: true,
            arguments: {},
            lazy: true, //doesnt work
            mode: "lazy" //doesnt work
        };
        if (job.highQueueLengthExpected) {
            options.arguments["x-queue-mode"] = "lazy"; //doesnt work
            options.arguments["queue-mode"] = "lazy"; //doesnt work
            options["x-queue-mode"] = "lazy"; //doesnt work
        }

        return ch.assertQueue(job.key, options).then(function (ok) {

我是 checking the mode 通过 RabbitMQ 的 HTTP API 触发的队列

curl  -u guest:guest 'localhost:15672/api/queues/{vhostName}/{queueName}'

对于我在声明队列时提供的所有选项,mode comes back as default

【问题讨论】:

    标签: node.js rabbitmq node-amqplib


    【解决方案1】:

    queueMode: 'lazy'

    为我工作。一般来说,我认为 amqplib 选项键是 amqp 功能或选项的驼峰式版本,删除了 x-。例如 amqp 中的 x-dead-letter-exchange 是 amqplib 中的 deadLetterExchange

    这仅适用于 amqplib v0.5.3 及更高版本。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-20
      • 1970-01-01
      相关资源
      最近更新 更多