【发布时间】:2018-02-05 21:51:59
【问题描述】:
我在 nodejs 应用程序中使用amqplib。前端有一些繁重的处理会导致接收rabbitmq消息时出现一些延迟。当使用rabbitmqctl list_queues 监控我的队列时,等待处理的消息数量永远不会停止攀升。
有没有办法设置我的频道以便在队列有给定数量的消息等待时丢弃消息?
以下是我设置频道的方法:
amqp.connect('amqp://localhost')
.then(conn => {
return conn.createChannel();
})
.then(channel => {
channel.assertQueue(q, {durable: false, autoDelete: true});
channel.prefetch(1);
channel.bindQueue(q.queue, topic, 'myroutingkey');
return channel.consume(q, (msg) => {
mycallback(channel, msg);
});
})
.then(() => {})
.catch(err => {});
【问题讨论】:
-
这有帮助吗? rabbitmq.com/maxlength.html
标签: node.js rabbitmq amqp node-amqplib