I am using official Node's AWS SDK and SQS module from this package
import { SQS } from 'aws-sdk';
What is the proper way of waiting for an SQS message?
My current implementation does
const message = await this.sqs.receiveMessage({ QueueUrl: url }).promise();
And I thought it would await until new message enters the queue but it doesn't work like that. It actually just returns object which does not contain Messages
key when there are no messages in queue.
My idea is to implement an interval and send this request every second or so but it seems like re-inventing the wheel.
What is the proper way of receiving messages from such queue?
You can use Node.js library called sqs-consumer
it is widely used.