各位好,
我刚学rabbitmq,现有个问题。我用的是rabbitmq+nodejs+amqplib,当我打开了noAck:false
chnl.consume('task_queue', doWork, {noAck: false});
function doWork(msg) {
var body = msg.content.toString();
console.log(" [x] Received '%s'", body);
var secs = body.split('.').length - 1;
console.log(" [x] Task takes %d seconds", secs);
setTimeout(function() {
console.log(" [x] Done");
if(body=='Hello World3!'){
//不会触发chnl.ack(msg)方法,用来模拟业务操作失败,这样这个hello world3!的消息也还在rabbitmq中,不会丢失,但我还是想这些消息再次进入queue中并能被再次取出,如发送邮件失败后还会再重新发送。请问如何再激活这条消息,难道非要重启这个程序吗?
}else{
console.log('ack');
chnl.ack(msg);
}
}, secs * 1000);
}
5 回复