0

我正在轮询 Amazon SQS 以获取新消息,并且正在尝试确定检查“无可用消息”的最佳方法。

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 
    }

这似乎不适用于检查“无可用消息”的方法。关于正确检查方法的任何想法?谢谢!

4

1 回答 1

1
ReceiveMessageResult r = receiveMessageResponse.ReceiveMessageResult;

if (r.Message.Count < 1)
{
  Console.WriteLine("Can't find any visible messages.");
}
于 2011-09-19T23:59:57.723 回答