How to use channel.consume to set up synchronous consumption?
Dooy opened this issue · comments
Dooy commented
The first message has not been processed yet, and the second message comes.
EG...
const processMessage = async message => {
try {
console.log(msg.content);
await sleep(2000);
console.log("hi");
channel.ack(message);
} catch(error) {
// handle errors
}
};
const ready = await channel.consume(queueAssertion.queue, processMessage, {
noAck: false
});
async function sleep(time){
return new Promise(h=>setTimeout(h,time));
}
Dooy commented
sorry , use channel.prefetch(1, true)
to achieve the effect