开发者

How to get precise number of messages in Amazon Simple Queue Service?

Currently, I am investigating the Amazon SQS. I am trying to get the number of messages in the queue.

The way I did is to sum up the number of ApproximateNumberOfMessages and ApproximateNumberOfMessagesNotVisible (which I got from Queue Attributes).

However, there are delay of 开发者_如何学Cupdating on Amazon sqs. For example, I will get 0 message in the queue if I just sent the message to the queue 5 seconds ago. I tried to wait for 1 minutes after sending the message to the queue. But, sometimes, it doesn't work.

So, I am wondering what the best way to capture this information. Thanks.


What you did was basically the only way of knowing that. SQS has eventual consistency which means its hard to get the exact real number.

For debugging purposes I suggest logging in the requests of adding to the queue and logging in the requests for pulling out of the queue.

You can also add some kind of a unique ID (or an incrementing ID) to each message so you can track it more easily.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜