AIntel AIntel - 1 month ago 9
Node.js Question

Amazon SQS doesn't supply my worker instance with the full message

I'm trying to queue up and process requests with SQS. I've set it up using a Node.JS worker on elastic beanstalk which automatically gets http posts from SQS when messages are added to it from another box.

The issue is, I'm unable to get all the necessary data from the http post to delete the message from the queue. The only data I see is the message data I entered myself in the body, but no MessageId or ReceiptHandle.

I am able to get those attributes when I manually call SQS.receiveMessage(queuerurl,callback) but only if I don't have the automatic http posting set up.

When I have SQS posting to my worker the message immediately goes into the queue and then into an invisible 'in flight' state which prevents any messages from coming through using SQS.receiveMessage(queuerurl,callback).

Can anyone explain what I'm missing here?

Am I misunderstanding the 'automatic message send' that SQS offers?

Thanks for the help

Answer

Elastic Beanstalk workers have a service on them that pulls messages from SQS and submits those messages to your code via HTTP. SQS itself isn't doing anything special here. It's the service on the beanstalk worker that manages polling SQS for messages and deletes those messages once they have been processed.

From the documentation:

When the application in the worker environment returns a 200 OK response to acknowledge that it has received and successfully processed the request, the daemon sends a DeleteMessage call to the SQS queue so that the message will be deleted from the queue.