如何列出包括AWS队列名称的队列

时间:2016-06-13 14:04:02

标签: c# amazon-sqs

我正在寻找一种从AWS获取队列名称列表的方法。我目前正在使用以下代码,但从AWS返回的列表仅包括队列URL(和其他属性),而不包括队列名称:

using (var sqsClient = new AmazonSQSClient(credentials, RegionEndpoint.EUWest1))
{
    ListQueuesResponse response = sqsClient.ListQueues(new Amazon.SQS.Model.ListQueuesRequest());
    List<QueueResponse> qrs = new List<QueueResponse>();
    foreach (var queueURL in response.QueueUrls)
    {
        GetQueueAttributesResponse attributesResponse = sqsClient.GetQueueAttributes(new GetQueueAttributesRequest(queueURL, new List<string> { "All" }));
        qrs.Add(new QueueResponse { QueueURL = queueURL, MessagesAvailable = attributesResponse.ApproximateNumberOfMessages, MessagesInFlight = attributesResponse.ApproximateNumberOfMessagesNotVisible  });
    }
}

我很感激任何解决上述问题的建议。

由于

1 个答案:

答案 0 :(得分:0)

'Try QueueARN which is something like this arn:aws:sqs:region:account-id:queuename '

 namespace Amazon.SQS.Model
{
   public class GetQueueAttributesResult : AmazonWebServiceResponse
   {
    public GetQueueAttributesResult();

    public int ApproximateNumberOfMessages { get; }
    public int ApproximateNumberOfMessagesDelayed { get; }
    public int ApproximateNumberOfMessagesNotVisible { get; }
    public Dictionary<string, string> Attributes { get; set; }
    public DateTime CreatedTimestamp { get; }
    public int DelaySeconds { get; }
    public DateTime LastModifiedTimestamp { get; }
    public int MaximumMessageSize { get; }
    public int MessageRetentionPeriod { get; }
    public string Policy { get; }
    public string QueueARN { get; }
    public int VisibilityTimeout { get; }
   }
}