Best way to check for "No available messages" in Amazon SQS?
I'm polling the Amazon SQS for new开发者_运维问答 messages and I'm trying to decide the best way to check for "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
}
This doesn't seem to work as a way to check for "No available messages". Any thoughts on the proper way to check? Thank you!
ReceiveMessageResult r = receiveMessageResponse.ReceiveMessageResult;
if (r.Message.Count < 1)
{
Console.WriteLine("Can't find any visible messages.");
}
精彩评论