I am trying to consume message from rabbitmq in node js. It's consuming properly. Here I am doing some operation (API call) during consuming message. Now I want to acknowledge once api responded 200 status only . Otherwise message will not deque. How can I do that ? Thanks in advance
let config = {
protocol: 'amqp',
hostname: '10.25.8.5',
username: '****',
password: '******'
};
amqp.connect(config, function(error0, connection) {
if (error0) {
throw error0;
}
connection.createChannel(function(error1, channel) {
if (error1) {throw error1;}
var queue = 'test_queue';
channel.assertQueue(queue, {
durable: false
});
console.log(" [*] Waiting for messages", queue);
channel.consume(queue, function(msg) {
let consumedData = msg.content.toString();
// Other process by calling api .
console.log(" [x] Received ", consumedData);
}, {
noAck: true
});
});
});