1

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

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

我尝试了以下方法:

        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

4

1 回答 1

1

queueMode: 'lazy'

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

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

于 2019-03-12T18:19:16.287 回答