当前位置: 首页>>代码示例>>C#>>正文


C# AmazonSQSClient.ListQueues方法代码示例

本文整理汇总了C#中Amazon.SQS.AmazonSQSClient.ListQueues方法的典型用法代码示例。如果您正苦于以下问题:C# AmazonSQSClient.ListQueues方法的具体用法?C# AmazonSQSClient.ListQueues怎么用?C# AmazonSQSClient.ListQueues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Amazon.SQS.AmazonSQSClient的用法示例。


在下文中一共展示了AmazonSQSClient.ListQueues方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeQueue

        private AmazonSQSClient InitializeQueue()
        {
            var client = new AmazonSQSClient(Utility.GetRegionEndpoint());
            
            ListQueuesRequest listQueuesRequest = new ListQueuesRequest
                                                      {
                                                          QueueNamePrefix = QueueName
                                                      };
            var listQueuesResponse = client.ListQueues(listQueuesRequest);
            bool found = listQueuesResponse.ListQueuesResult.QueueUrls.Any(s => s == QueueName);

            if (found == false)
            {
                var createQueueResponse = client.CreateQueue(new CreateQueueRequest
                                                                 {
                                                                     QueueName = QueueName
                                                                 });
                QueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;
            }
            else
            {
                QueueUrl = client.GetQueueUrl(
                    new GetQueueUrlRequest
                        {
                            QueueName = _queueName
                        }
                    ).GetQueueUrlResult.QueueUrl;
            }
            return client;
        }
开发者ID:EdsonF,项目名称:log4net.aws,代码行数:30,代码来源:SQSAppender.cs

示例2: When_obtaining_details_on_a_message_queue

        public void When_obtaining_details_on_a_message_queue(string queueName, bool exists)
        {
            // Arrange
            var client = new AmazonSQSClient("access key", "secret key");

            if (exists)
            {
                client.CreateQueue(new CreateQueueRequest().WithQueueName(queueName));
            }
            else
            {
                var response = client.ListQueues(new ListQueuesRequest().WithQueueNamePrefix(queueName));
                if (response.ListQueuesResult.QueueUrl.Any())
                {
                    client.DeleteQueue(new DeleteQueueRequest().WithQueueUrl(response.ListQueuesResult.QueueUrl.First()));
                }
            }

            Thread.Sleep(2000); // Give the queues some time to spin up
          
            var factory = new AmazonSqsMessageQueueDetailFactory(client);


            // Act
            var result = factory.Build<TestMessage>(queueName);

            // Assert
            Assert.That(result.Uri, Is.StringContaining(queueName));
            Assert.That(result.Exists, Is.EqualTo(exists));
        }  
开发者ID:jrolstad,项目名称:Simple.Messaging,代码行数:30,代码来源:AmazonSqsMessageQueueDetailFactoryTests.cs

示例3: DeleteAllQueues

        public static void DeleteAllQueues()
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var response = client.ListQueues(new ListQueuesRequest());

                foreach (var queueUrl in response.QueueUrls)
                {
                    PurgeQueueByQueueUrl(queueUrl);

                    client.DeleteQueue(queueUrl);
                }
            }
        }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:14,代码来源:Repository.cs

示例4: Main

        public static void Main(string[] args)
        {
            IAmazonSQS sqs = new AmazonSQSClient(RegionEndpoint.USWest2);

            try
            {
                Console.WriteLine("===========================================");
                Console.WriteLine("Getting Started with Amazon SQS");
                Console.WriteLine("===========================================\n");                
                
                //Creating a queue
                Console.WriteLine("Create a queue called MyQueue.\n");
                CreateQueueRequest sqsRequest = new CreateQueueRequest();
                sqsRequest.QueueName = "MyQueue";
                CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest);
                String myQueueUrl;
                myQueueUrl = createQueueResponse.QueueUrl;

                //Confirming the queue exists
                ListQueuesRequest listQueuesRequest = new ListQueuesRequest();
                ListQueuesResponse listQueuesResponse = sqs.ListQueues(listQueuesRequest);

                Console.WriteLine("Printing list of Amazon SQS queues.\n");
                foreach (String queueUrl in listQueuesResponse.QueueUrls)
                {
                    Console.WriteLine("  QueueUrl: {0}", queueUrl);
                }
                Console.WriteLine();

                //Sending a message
                Console.WriteLine("Sending a message to MyQueue.\n");
                SendMessageRequest sendMessageRequest = new SendMessageRequest();
                sendMessageRequest.QueueUrl = myQueueUrl; //URL from initial queue creation
                sendMessageRequest.MessageBody = "This is my message text.";
                sqs.SendMessage(sendMessageRequest);
                
                //Receiving a message
                ReceiveMessageRequest receiveMessageRequest = new ReceiveMessageRequest();
                receiveMessageRequest.QueueUrl = myQueueUrl;
                ReceiveMessageResponse receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);

                Console.WriteLine("Printing received message.\n");
                foreach (Message message in receiveMessageResponse.Messages)
                {
                    Console.WriteLine("  Message");
                    Console.WriteLine("    MessageId: {0}", message.MessageId);
                    Console.WriteLine("    ReceiptHandle: {0}", message.ReceiptHandle);
                    Console.WriteLine("    MD5OfBody: {0}", message.MD5OfBody);
                    Console.WriteLine("    Body: {0}", message.Body);

                    foreach (KeyValuePair<string, string> entry in message.Attributes)
                    {
                        Console.WriteLine("  Attribute");
                        Console.WriteLine("    Name: {0}", entry.Key);
                        Console.WriteLine("    Value: {0}", entry.Value);
                    }
                }
                String messageRecieptHandle = receiveMessageResponse.Messages[0].ReceiptHandle;

                //Deleting a message
                Console.WriteLine("Deleting the message.\n");
                DeleteMessageRequest deleteRequest = new DeleteMessageRequest();
                deleteRequest.QueueUrl = myQueueUrl;
                deleteRequest.ReceiptHandle = messageRecieptHandle;
                sqs.DeleteMessage(deleteRequest);

            }
            catch (AmazonSQSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
                Console.WriteLine("Request ID: " + ex.RequestId);
            }

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
开发者ID:jamisliao,项目名称:aws-sdk-net-samples,代码行数:79,代码来源:Program.cs

示例5: AppMode_TestSqsAccess

 public virtual bool AppMode_TestSqsAccess(RegionEndpoint regionEndpoint, SessionAWSCredentials credentials)
 {
     try
     {
         var sqsClient = new AmazonSQSClient(credentials, regionEndpoint);
         sqsClient.ListQueues(new ListQueuesRequest());
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:jfaerman,项目名称:devonaws-labs-csharp,代码行数:13,代码来源:SolutionCode.cs

示例6: Main

        public static void Main(string[] args)
        {
            var sqs = new AmazonSQSClient();

            try
            {
                Console.WriteLine("===========================================");
                Console.WriteLine("Getting Started with Amazon SQS");
                Console.WriteLine("===========================================\n");

                //Confirming the queue exists
                var listQueuesRequest = new ListQueuesRequest();
                var listQueuesResponse = sqs.ListQueues(listQueuesRequest);
                string myQueueUrl = string.Empty;

                Console.WriteLine("Printing list of Amazon SQS queues.\n");
                bool queueExists = false;
                if (listQueuesResponse.QueueUrls != null)
                {
                    foreach (String queueUrl in listQueuesResponse.QueueUrls)
                    {
                        Console.WriteLine("  QueueUrl: {0}", queueUrl);
                        if (queueUrl.EndsWith("MyQueue"))
                        {
                            queueExists = true;
                            myQueueUrl = queueUrl;
                            break;
                        }
                    }
                }
                Console.WriteLine();

                if (!queueExists)
                {
                    //Creating a queue
                    Console.WriteLine("Create a queue called MyQueue.\n");
                    var sqsRequest = new CreateQueueRequest { QueueName = "MyQueue" };
                    var createQueueResponse = sqs.CreateQueue(sqsRequest);
                    myQueueUrl = createQueueResponse.QueueUrl;
                }

                //Sending a message
                Console.WriteLine("Sending a message to MyQueue.\n");
                var sendMessageRequest = new SendMessageRequest
                    {
                        QueueUrl = myQueueUrl, //URL from initial queue creation
                        MessageBody = string.Format("ATL MEETUP - This is my message text from server - {0}",System.Environment.MachineName)
                    };
                sqs.SendMessage(sendMessageRequest);

                ////Receiving a message
                //var receiveMessageRequest = new ReceiveMessageRequest { QueueUrl = myQueueUrl };
                //var receiveMessageResponse = sqs.ReceiveMessage(receiveMessageRequest);
                //if (receiveMessageResponse.Messages != null)
                //{
                //    Console.WriteLine("Printing received message.\n");
                //    foreach (var message in receiveMessageResponse.Messages)
                //    {
                //        Console.WriteLine("  Message");
                //        if (!string.IsNullOrEmpty(message.MessageId))
                //        {
                //            Console.WriteLine("    MessageId: {0}", message.MessageId);
                //        }
                //        if (!string.IsNullOrEmpty(message.ReceiptHandle))
                //        {
                //            Console.WriteLine("    ReceiptHandle: {0}", message.ReceiptHandle);
                //        }
                //        if (!string.IsNullOrEmpty(message.MD5OfBody))
                //        {
                //            Console.WriteLine("    MD5OfBody: {0}", message.MD5OfBody);
                //        }
                //        if (!string.IsNullOrEmpty(message.Body))
                //        {
                //            Console.WriteLine("    Body: {0}", message.Body);
                //        }

                //        foreach (string attributeKey in message.Attributes.Keys)
                //        {
                //            Console.WriteLine("  Attribute");
                //            Console.WriteLine("    Name: {0}", attributeKey);
                //            var value = message.Attributes[attributeKey];
                //            Console.WriteLine("    Value: {0}", string.IsNullOrEmpty(value) ? "(no value)" : value);
                //        }
                //    }

                //    var messageRecieptHandle = receiveMessageResponse.Messages[0].ReceiptHandle;

                //    //Deleting a message
                //    Console.WriteLine("Deleting the message.\n");
                //    var deleteRequest = new DeleteMessageRequest { QueueUrl = myQueueUrl, ReceiptHandle = messageRecieptHandle };
                //    sqs.DeleteMessage(deleteRequest);
                //}

            }
            catch (AmazonSQSException ex)
            {
                Console.WriteLine("Caught Exception: " + ex.Message);
                Console.WriteLine("Response Status Code: " + ex.StatusCode);
                Console.WriteLine("Error Code: " + ex.ErrorCode);
                Console.WriteLine("Error Type: " + ex.ErrorType);
//.........这里部分代码省略.........
开发者ID:developertofu,项目名称:DotNetCodeDeploy,代码行数:101,代码来源:Program.cs

示例7: GetSQSQ

        public DataTable GetSQSQ(string aprofile, string Region2Scan)
        {
            DataTable ToReturn = new DataTable();

            string accountid = GetAccountID(aprofile);

            RegionEndpoint Endpoint2scan = RegionEndpoint.USEast1;
            //Convert the Region2Scan to an AWS Endpoint.
            foreach (var aregion in RegionEndpoint.EnumerableAllRegions)
            {
                if (aregion.DisplayName.Equals(Region2Scan))
                {
                    Endpoint2scan = aregion;
                    continue;
                }
            }
            Amazon.Runtime.AWSCredentials credential;

            try
            {
                credential = new Amazon.Runtime.StoredProfileAWSCredentials(aprofile);
                var sqsq = new Amazon.SQS.AmazonSQSClient(credential, Endpoint2scan);
                var daqs = sqsq.ListQueues("").QueueUrls;

            }
            catch
            {

            }




            return ToReturn;

        }
开发者ID:StivOstenberg,项目名称:AWSTrycorder,代码行数:36,代码来源:AWSFunctions.cs

示例8: SQSListQueues

    public static void SQSListQueues()
    {
      #region SQSListQueues
      var client = new AmazonSQSClient();

      // List all queues that start with "My".
      var request = new ListQueuesRequest
      {
        QueueNamePrefix = "My"
      };

      var response = client.ListQueues(request);

      if (response.QueueUrls.Count > 0)
      {
        Console.WriteLine("Queue URLs:");

        foreach (var url in response.QueueUrls)
        {
          Console.WriteLine("  " + url);
        }
      }
      else
      {
        Console.WriteLine("No matching queues.");
      }
      #endregion

      Console.ReadLine();
    }
开发者ID:rajdotnet,项目名称:aws-sdk-net,代码行数:30,代码来源:SQSSamples.cs

示例9: FindQueueUrls

        public static IEnumerable<string> FindQueueUrls()
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                var response = client.ListQueues(new ListQueuesRequest());

                foreach (var queueUrl in response.QueueUrls)
                {
                    yield return queueUrl;
                }
            }
        }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:12,代码来源:Repository.cs

示例10: FindQueueUrlByQueueName

        public static string FindQueueUrlByQueueName(string name)
        {
            using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret))
            {
                ListQueuesResponse response = client.ListQueues(new ListQueuesRequest(name));

                foreach (string queueUrl in response.QueueUrls)
                {
                    return queueUrl;
                }
            }

            return null;
        }
开发者ID:korz,项目名称:IntroductionToAmazonAws,代码行数:14,代码来源:Repository.cs


注:本文中的Amazon.SQS.AmazonSQSClient.ListQueues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。