With example in rabbitmq, consumer get all messages from queue at one time. How to consume one message and exit?
QueueingConsumer consumer = new QueueingCons
const consumeFromQueue = async (queueName) => {
try {
let data = await channel.get(queueName)// get one msg at a time
if (data) {
data.content ? eval("(" + data.content.toString() + ")()") : ""
channel.ack(data)
} else {
//console.log("Empty Queue")
}
}
catch (error) {
//console.log("Error while consuming from rabbitmq queue", error)
return Promise.reject(error)
}
}