no message == empty queue?
whyvez opened this issue · 1 comments
whyvez commented
Is it safe to assume that if no message is returned from receiveMessage
that the queue is empty?
I am using the following logic:
const { id, message } = await rsmq.receiveMessage({ qname });
if (!message) {
log.info('Successfully processed queue.');
process.exit(0);
}
In my case, the process exits prematurely before the queue is empty, how could this happen?
exinferis commented
Since messages have a visibility timeout after being received they still remain in the queue but are not delivered, when using receiveMessage
.
So no - it is wrong to assume for the queue to be empty just because you don't retrieve a message currently. getQueueAttributes
should give you insights of the selected queue including the total message count.