我有一个 WPF 应用程序,它向 Amazon SQS 发送消息。
在接收端,我可以从亚马逊队列接收消息并进行进一步处理。接收端的代码示例如下:
ReceiveMessageRequest receivemsgRequest = new ReceiveMessageRequest();
receivemsgRequest.QueueUrl = queueUrl;
ReceiveMessageResponse receivemsgResp = sqs.ReceiveMessage(receivemsgRequest);
if (receivemsgResp.IsSetReceiveMessageResult())
{
Console.WriteLine("Messages are : ");
ReceiveMessageResult rcvMsgResult = receivemsgResp.ReceiveMessageResult;
foreach (Message msg in rcvMsgResult.Message)
{
Console.WriteLine("Message - " + msg.Body.ToString());
}
}
现在我想要接收端的服务,继续运行上面的代码来检查队列中是否存在任何消息。Windows 服务 (WCF) 会完成这项任务,还是有更好的方法来完成这项任务?