Multiple consumers but 1 message in flight?

0

Hi,

I'm using this library (https://github.com/BBC/sqs-consumer) to consume messages from my queue. I have a small node app built that I'm running on my EC2 instance (using pm2 I do multiple npm start).

My expected outcome would be that there would be multiple messages in flight (I have 2 EC2 instances, 10 processes on each).

The actual outcome is that in the SQS dashboard I constantly see 1 message in flight.

My queue config

已提问 1 年前1124 查看次数
2 回答
1
已接受的回答

You don't say whether you're specifying the MessageGroupId or not when sending the message so I'm going to assume for a moment that you're using a single group id.

Looking at the documentation for FIFO delivery logic what happens is that the ReceiveMessage call gets the number of messages you ask for (default is 1, maximum is 10) and then will not receive any more messages from the same group id until those message(s) have been deleted or are visible again. This is to ensure that messages are delivered in the correct order - which is what FIFO queues offer.

You can have multiple messages in flight if you use multiple group ids - but then ordering is only within the groups rather than the queue as a whole. Then you can have as many messages in flight (assuming you get one at a time) as you have unique group ids.

If ordering isn't important then a non-FIFO queue might be the way to go.

profile pictureAWS
专家
已回答 1 年前
  • thank you, just as I realised this myself I saw your answer :)

0

Apologies, I'm not sure how to close the question. My mistake was that I was sending the same MessageGroupId for every message to this queue, when in fact I shouldn't have. This allows multiple processors to consume the queue.

已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则