【问题标题】:Is there any way to check whether a task or message exists in Rabbitmq queue ? The idea is to eliminate duplicate tasks going into the queue有什么方法可以检查 Rabbitmq 队列中是否存在任务或消息?这个想法是消除进入队列的重复任务
【发布时间】:2020-03-16 11:15:57
【问题描述】:

我正在将文件名保存在 rabbitmq 队列中的任务或消息中。我想确保没有创建具有相同文件名的重复任务。有什么方法可以确保rabbitmq 拒绝重复或至少检查该文件名是否存在于队列中?

以下是代码:

ch.assertQueue(insertImg, { durable: true }).then(() => {
ch.sendToQueue(insertImg, Buffer.from(zipFileName));
resolve();
})


ch.assertQueue(insertImg, { durable: true }).then(async () => {
await ch.prefetch(1);
return ch.consume(insertImg, async function (fileName) {}, { noAck: false });
});

【问题讨论】:

    标签: javascript node.js mongodb rabbitmq


    【解决方案1】:

    RabbitMQ 队列内容不容易检查。唯一可行的方法是获取其中包含的所有消息并在消费者端检查它们。

    如果您正在寻找消息重复数据删除,则有一个 plugin 用于丢弃代理上的重复消息。

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 2014-06-18
      • 1970-01-01
      • 1970-01-01
      • 2021-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多