app consuming more than one message at a time, in single-message (not batch) mode
Hi,
My app seems to consume and process messages simultaneously, even though I am using handleMessage option not handleMessageBatch().
It is really important to my application that messages are consumed one-at-a-time
If you're using handleMessage and you're using the default batch size (1) but then messages won't be processed simultaneously.
I wasn't setting the batchSize anywhere in my application, so the default should be 1, right? I have inspected using DEBUG=sqs-consumer in my .env and I am definitely receiving message B before message A's handleMessage function has resolved
You're not spawning workers (manually or using pm2, for example), running on multiple redundant servers or running the process multiple times? In those cases you will experience messages being consumed "simultaneously".
The plan in production is to spawn multiple workers pointing at the same queue yes, but right now I am just testing locally on one machine with a simple sleep(5000) function in the handleMessage!
can you post your handlers code?
handleSQS.js
const handleSQSMessage = async (message) => {
const sleep = new Promise((resolve, reject) => {
setTimeout(() => resolve('done!'), 5000);
});
return await sleep;
};
index.js
const sqsapp = Consumer.create({
queueUrl: auditQueueURL,
messageAttributeNames: ['All'],
attributeNames: ['All'],
handleMessage: handleSQSMessage,
visibilityTimeout: process.env.MSG_EXTENSION_TIME,
handleMessageTimeout: process.env.MSG_TOTAL_TIME_LIMIT,
batchSize: 1,
});
Hey, can anyone help me here? I need to await inside the handleMessage function, and not pick up any more messages until the handleMessage has either rejected or resolved. How can I achieve this?
Closing issue since #167 has been raised.
I can attest that this issue has NOT been resolved. Please see https://github.com/bbc/sqs-consumer/issues/256