检查“没有可用消息”的最佳方法在亚马逊SQS

本文关键字:最佳 方法 SQS 亚马逊 消息 检查 | 更新日期: 2023-09-27 18:08:56

我正在为Amazon SQS轮询新消息,我正在尝试决定检查"No available messages"的最佳方法。

AmazonSQS sqs = new AmazonSQS();  //pseudo code this line
ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
receiveMessageRequest.QueueUrl = myQueueUrl;
ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);
if (receiveMessageResponse.IsSetReceiveMessageResult())
    {
        //Always TRUE even if there are no untaken messages 
    }

这似乎不能作为检查"No available messages"的方法。有什么正确的检查方法吗?谢谢你!

检查“没有可用消息”的最佳方法在亚马逊SQS

ReceiveMessageResult r = receiveMessageResponse.ReceiveMessageResult;
if (r.Message.Count < 1)
{
  Console.WriteLine("Can't find any visible messages.");
}