Container for the parameters to the ListQueues operation. Returns a list of your queues. The maximum number of queues that can be returned is 1,000. If you specify a value for the optional QueueNamePrefix parameter, only queues with a name that begins with the specified value are returned.
Inheritance: AmazonSQSRequest
Example #1
2
        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;
        }
 public static string ListSQSQueues()
 {
     AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient();
     ListQueuesRequest sqsrequest = new ListQueuesRequest();
     ListQueuesResponse sqsresponse = sqs.ListQueues(sqsrequest);
     ListQueuesResult sqsrst = sqsresponse.ListQueuesResult;
     return sqsrst.ToString();
 }
        protected override void EndProcessing()
        {
            AmazonSQS client = GetClient();
            ListQueuesRequest request = new ListQueuesRequest();
            request.QueueNamePrefix = this.QueueNamePrefix;

            ListQueuesResponse response = client.ListQueues(request);

            WriteObject(response.ListQueuesResult.QueueUrl, true);
        }
Example #4
0
        /// <summary>
        /// Gets a list of all registered message queues
        /// </summary>
        /// <param name="listQueuesRequest">The list queue request object.</param>
        /// <returns>A list of all registered message queues.</returns>
        public virtual ListQueuesResponse GetAllQueueNames(ListQueuesRequest listQueuesRequest)
        {
            if (listQueuesRequest == null)
            {
                throw new ArgumentNullException("listQueuesRequest");
            }

            // Log.Debug("SqsClient: Getting all queue names");
            var listQueuesResponse = this.Client.ListQueues(listQueuesRequest);
            if (!listQueuesResponse.IsSetListQueuesResult())
            {
                throw new InvalidOperationException("Could not retrieve list of message queues from Amazon SQS.");
            }

            return listQueuesResponse;
        }
Example #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            CreateQueueRequest sqsRequest = new CreateQueueRequest();
            sqsRequest.QueueName = "MYFirstQueue";
            CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest);
            myQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;

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

            SendMessageRequest sendMessageRequest = new SendMessageRequest();
            sendMessageRequest.QueueUrl = myQueueUrl;
            sendMessageRequest.MessageBody = txtPushMsg.Text;
            sqs.SendMessage(sendMessageRequest);
        }
Example #6
0
        public ObservableCollection<QueueDescription> ListQueues()
        {
            var lqr = new ListQueuesRequest();
            var response = this.client.ListQueues(lqr);

            var result = new ObservableCollection<QueueDescription>();

            foreach (string url in response.QueueUrls) {
                string name = url.Substring(url.LastIndexOf('/') + 1);
                result.Add(new QueueDescription() {
                    Name = name,
                    Url = url
                });
            }

            return result;
        }
Example #7
0
File: Main.cs Project: mloar/sirisx
        private static void FindOrCreateSQSQueue(AmazonSQS sqs)
        {
            //Confirming the queue exists
            ListQueuesRequest listQueuesRequest = new ListQueuesRequest();
            ListQueuesResponse listQueuesResponse = sqs.ListQueues(listQueuesRequest);

            Console.WriteLine("Printing list of Amazon SQS queues.\n");
            if (listQueuesResponse.IsSetListQueuesResult())
            {
                ListQueuesResult listQueuesResult = listQueuesResponse.ListQueuesResult;
                foreach (String queueUrl in listQueuesResult.QueueUrl)
                {
                    Console.WriteLine("  QueueUrl: {0}", queueUrl);
                }
            }
            Console.WriteLine();
        }
Example #8
0
        /// <summary>
        /// 
        /// The ListQueues action returns a list of your queues.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonSQS service</param>
        /// <param name="request">ListQueuesRequest request</param>
        public static void InvokeListQueues(AmazonSQS service, ListQueuesRequest request)
        {
            try 
            {
                ListQueuesResponse response = service.ListQueues(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        ListQueuesResponse");
                if (response.IsSetListQueuesResult()) 
                {
                    Console.WriteLine("            ListQueuesResult");
                    ListQueuesResult  listQueuesResult = response.ListQueuesResult;
                    List<String> queueUrlList  =  listQueuesResult.QueueUrl;
                    foreach (String queueUrl in queueUrlList) 
                    { 
                        Console.WriteLine("                QueueUrl");
                        Console.WriteLine("                    {0}", queueUrl);
                    }	
                } 
                if (response.IsSetResponseMetadata()) 
                {
                    Console.WriteLine("            ResponseMetadata");
                    ResponseMetadata  responseMetadata = response.ResponseMetadata;
                    if (responseMetadata.IsSetRequestId()) 
                    {
                        Console.WriteLine("                RequestId");
                        Console.WriteLine("                    {0}", responseMetadata.RequestId);
                    }
                } 

            } 
            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("XML: " + ex.XML);
            }
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SQS.Model.ListQueuesRequest();

            if (cmdletContext.MaxResult != null)
            {
                request.MaxResults = cmdletContext.MaxResult.Value;
            }
            if (cmdletContext.NextToken != null)
            {
                request.NextToken = cmdletContext.NextToken;
            }
            if (cmdletContext.QueueNamePrefix != null)
            {
                request.QueueNamePrefix = cmdletContext.QueueNamePrefix;
            }

            CmdletOutput output;

            // issue call
            var client = Client ?? CreateClient(_CurrentCredentials, _RegionEndpoint);

            try
            {
                var    response       = CallAWSServiceOperation(client, request);
                object pipelineOutput = null;
                pipelineOutput = cmdletContext.Select(response, this);
                output         = new CmdletOutput
                {
                    PipelineOutput  = pipelineOutput,
                    ServiceResponse = response
                };
            }
            catch (Exception e)
            {
                output = new CmdletOutput {
                    ErrorResponse = e
                };
            }

            return(output);
        }
        public virtual bool DoesQueueExist(string queueName)
        {
            var exists = false;
            var client = this.GetClient();
            var request = new ListQueuesRequest
                              {
                                  QueueNamePrefix = queueName
                              };
            var response = client.ListQueues(request);

            response.ListQueuesResult.QueueUrl.ForEach(x =>
                                                           {
                                                               if (x.EndsWith(queueName))
                                                               {
                                                                   exists = true;
                                                               }
                                                           });

            return exists;
        }
        /// <summary>
        /// Initiates the asynchronous execution of the ListQueues operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListQueues operation on AmazonSQSClient.</param>
        /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
        /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
        ///          procedure using the AsyncState property.</param>
        /// 
        /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListQueues
        ///         operation.</returns>
        public IAsyncResult BeginListQueues(ListQueuesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new ListQueuesRequestMarshaller();
            var unmarshaller = ListQueuesResponseUnmarshaller.Instance;

            return BeginInvoke<ListQueuesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
 /// <summary>
 /// Returns a list of your queues. The maximum number of      queues that can be returned
 /// is 1000. If you specify a value for the optional      <code>QueueNamePrefix</code>
 /// parameter, only queues with a name beginning with the      specified value are returned.
 /// </summary>
 /// <param name="queueNamePrefix">A string to use for filtering the list results. Only those queues whose name   begins with the specified string are returned.</param>
 /// 
 /// <returns>The response from the ListQueues service method, as returned by SQS.</returns>
 public ListQueuesResponse ListQueues(string queueNamePrefix)
 {
     var request = new ListQueuesRequest();
     request.QueueNamePrefix = queueNamePrefix;
     return ListQueues(request);
 }
        /// <summary>
        /// Returns a list of your queues. The maximum number of      queues that can be returned
        /// is 1000. If you specify a value for the optional      <code>QueueNamePrefix</code>
        /// parameter, only queues with a name beginning with the      specified value are returned.
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the ListQueues service method.</param>
        /// 
        /// <returns>The response from the ListQueues service method, as returned by SQS.</returns>
        public ListQueuesResponse ListQueues(ListQueuesRequest request)
        {
            var marshaller = new ListQueuesRequestMarshaller();
            var unmarshaller = ListQueuesResponseUnmarshaller.Instance;

            return Invoke<ListQueuesRequest,ListQueuesResponse>(request, marshaller, unmarshaller);
        }
Example #14
0
 /// <summary>
 /// Returns a list of your queues. The maximum number of queues that can be returned is
 /// 1,000. If you specify a value for the optional <code>QueueNamePrefix</code> parameter,
 /// only queues with a name that begins with the specified value are returned.
 /// </summary>
 /// <param name="queueNamePrefix">A string to use for filtering the list results. Only those queues whose name begins with the specified string are returned. Queue names are case-sensitive.</param>
 /// <param name="cancellationToken">
 ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
 /// </param>
 /// 
 /// <returns>The response from the ListQueues service method, as returned by SQS.</returns>
 public Task<ListQueuesResponse> ListQueuesAsync(string queueNamePrefix, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new ListQueuesRequest();
     request.QueueNamePrefix = queueNamePrefix;
     return ListQueuesAsync(request, cancellationToken);
 }
Example #15
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListQueues operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListQueues operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        public Task<ListQueuesResponse> ListQueuesAsync(ListQueuesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListQueuesRequestMarshaller();
            var unmarshaller = ListQueuesResponseUnmarshaller.Instance;

            return InvokeAsync<ListQueuesRequest,ListQueuesResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
 /// <summary>
 /// Initiates the asynchronous execution of the ListQueues operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the ListQueues operation on AmazonSQSClient.</param>
 /// <param name="callback">An Action delegate that is invoked when the operation completes.</param>
 /// <param name="options">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 public void ListQueuesAsync(ListQueuesRequest request, AmazonServiceCallback<ListQueuesRequest, ListQueuesResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new ListQueuesRequestMarshaller();
     var unmarshaller = ListQueuesResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<ListQueuesRequest,ListQueuesResponse> responseObject 
                     = new AmazonServiceResult<ListQueuesRequest,ListQueuesResponse>((ListQueuesRequest)req, (ListQueuesResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<ListQueuesRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
Example #17
0
 IAsyncResult invokeListQueues(ListQueuesRequest listQueuesRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new ListQueuesRequestMarshaller().Marshall(listQueuesRequest);
     var unmarshaller = ListQueuesResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
 /// <summary>
 /// Paginator for ListQueues operation
 ///</summary>
 public IListQueuesPaginator ListQueues(ListQueuesRequest request)
 {
     return(new ListQueuesPaginator(this.client, request));
 }
		internal ListQueuesResponse ListQueues(ListQueuesRequest request)
        {
            var task = ListQueuesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Example #20
0
        public static void Main(string[] args)
        {
            NameValueCollection appConfig = ConfigurationManager.AppSettings;

            AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient(
                appConfig["AWSAccessKey"],
                appConfig["AWSSecretKey"]
                );

            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.CreateQueueResult.QueueUrl;

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

                Console.WriteLine("Printing list of Amazon SQS queues.\n");
                if (listQueuesResponse.IsSetListQueuesResult())
                {
                    ListQueuesResult listQueuesResult = listQueuesResponse.ListQueuesResult;
                    foreach (String queueUrl in listQueuesResult.QueueUrl)
                    {
                        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);
                if (receiveMessageResponse.IsSetReceiveMessageResult())
                {
                    Console.WriteLine("Printing received message.\n");
                    ReceiveMessageResult receiveMessageResult = receiveMessageResponse.ReceiveMessageResult;
                    foreach (Message message in receiveMessageResult.Message)
                    {
                        Console.WriteLine("  Message");
                        if (message.IsSetMessageId())
                        {
                            Console.WriteLine("    MessageId: {0}", message.MessageId);
                        }
                        if (message.IsSetReceiptHandle())
                        {
                            Console.WriteLine("    ReceiptHandle: {0}", message.ReceiptHandle);
                        }
                        if (message.IsSetMD5OfBody())
                        {
                            Console.WriteLine("    MD5OfBody: {0}", message.MD5OfBody);
                        }
                        if (message.IsSetBody())
                        {
                            Console.WriteLine("    Body: {0}", message.Body);
                        }
                        foreach (Amazon.SQS.Model.Attribute attribute in message.Attribute)
                        {
                            Console.WriteLine("  Attribute");
                            if (attribute.IsSetName())
                            {
                                Console.WriteLine("    Name: {0}", attribute.Name);
                            }
                            if (attribute.IsSetValue())
                            {
                                Console.WriteLine("    Value: {0}", attribute.Value);
                            }
                        }
                    }
                }
                String messageRecieptHandle = receiveMessageResponse.ReceiveMessageResult.Message[0].ReceiptHandle;

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

            }
            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("XML: " + ex.XML);
            }

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
 private Amazon.SQS.Model.ListQueuesResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.ListQueuesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "ListQueues");
     try
     {
         #if DESKTOP
         return(client.ListQueues(request));
         #elif CORECLR
         return(client.ListQueuesAsync(request).GetAwaiter().GetResult());
         #else
                 #error "Unknown build edition"
         #endif
     }
     catch (AmazonServiceException exc)
     {
         var webException = exc.InnerException as System.Net.WebException;
         if (webException != null)
         {
             throw new Exception(Utils.Common.FormatNameResolutionFailureMessage(client.Config, webException.Message), webException);
         }
         throw;
     }
 }
        public void Test_A_ListQueues_And_Check_For_NonNull_Response()
        {
            bool hasCallbackArrived = false;
            bool actualValue = false;
            bool expectedValue = true;

            SQSResponseEventHandler<object, ResponseEventArgs> handler = null;

            handler = delegate(object sender, ResponseEventArgs args)
            {
                ISQSResponse result = args.Response;
                //Unhook from event.
                _client.OnSQSResponse -= handler;
                ListQueuesResponse response = result as ListQueuesResponse;
                if (null != response)
                    actualValue = true;

                hasCallbackArrived = true;
            };

            //Hook to event
            _client.OnSQSResponse += handler;

            //Create request object.
            ListQueuesRequest listQueue = new ListQueuesRequest();
            _client.ListQueues(listQueue);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
Example #23
0
        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);
                Console.WriteLine("Request ID: " + ex.RequestId);
            }

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
Example #24
0
        private void btnListQueue_Click(object sender, RoutedEventArgs e)
        {
            ListQueuesRequest listQueue = new ListQueuesRequest();

            this.Dispatcher.BeginInvoke(() =>
            {
                this.QueueNames.Clear();
                this.QueueNames.Add("Please wait...");
            });
            sqs.OnSQSResponse += GetListQueueResponse;
            sqs.ListQueues(listQueue);
        }
Example #25
0
        /// <summary>
        /// Initiates the asynchronous execution of the ListQueues operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS.ListQueues"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListQueues operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
		public async Task<ListQueuesResponse> ListQueuesAsync(ListQueuesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListQueuesRequestMarshaller();
            var unmarshaller = ListQueuesResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, ListQueuesRequest, ListQueuesResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Example #26
0
 public Task<ListQueuesResponse> ListQueuesAsync(ListQueuesRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
Example #27
0
        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();
        }
 /// <summary>Check to see if our queue already exists in SQS</summary>
 /// <returns>True if the queue already exists</returns>
 private bool DoesQueueExist()
 {
     Project.Log(Level.Info, "Checking to see if queue exists...");
     using (Client) {
         try {
             var request = new ListQueuesRequest();
             var response = Client.ListQueues(request);
             if (response.IsSetListQueuesResult()) {
                 var result = response.ListQueuesResult;
                 foreach (var queueUrl in result.QueueUrl) {
                     if (queueUrl.Contains(QueueName)) {
                         Project.Log(Level.Info, "Queue '{0}' exists with URL: {1}", QueueName, queueUrl);
                         return true;
                     }
                 }
             }
         } catch (AmazonS3Exception ex) {
             ShowError(ex);
         }
     }
     Project.Log(Level.Info, "Queue '{0}' doesn't exist!", QueueName);
     return false;
 }
 internal ListQueuesPaginator(IAmazonSQS client, ListQueuesRequest request)
 {
     this._client  = client;
     this._request = request;
 }
Example #30
0
 /// <summary>
 /// <para>Returns a list of your queues.</para>
 /// </summary>
 /// 
 /// <param name="listQueuesRequest">Container for the necessary parameters to execute the ListQueues service method on AmazonSQS.</param>
 /// 
 /// <returns>The response from the ListQueues service method, as returned by AmazonSQS.</returns>
 /// 
 public ListQueuesResponse ListQueues(ListQueuesRequest listQueuesRequest)
 {
     IAsyncResult asyncResult = invokeListQueues(listQueuesRequest, null, null, true);
     return EndListQueues(asyncResult);
 }
Example #31
0
        /// <summary>
        /// <para>Returns a list of your queues. The maximum number of queues that can be returned is 1000. If you specify a value for the optional
        /// <c>QueueNamePrefix</c> parameter, only queues with a name beginning with the specified value are returned.</para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the ListQueues service method on AmazonSQS.</param>
        /// 
        /// <returns>The response from the ListQueues service method, as returned by AmazonSQS.</returns>
		public ListQueuesResponse ListQueues(ListQueuesRequest request)
        {
            var task = ListQueuesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Example #32
0
 /// <summary>
 /// Initiates the asynchronous execution of the ListQueues operation.
 /// <seealso cref="Amazon.SQS.IAmazonSQS.ListQueues"/>
 /// </summary>
 /// 
 /// <param name="listQueuesRequest">Container for the necessary parameters to execute the ListQueues operation on AmazonSQS.</param>
 /// <param name="callback">An AsyncCallback delegate that is invoked when the operation completes.</param>
 /// <param name="state">A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback
 ///          procedure using the AsyncState property.</param>
 /// 
 /// <returns>An IAsyncResult that can be used to poll or wait for results, or both; this value is also needed when invoking EndListQueues
 ///         operation.</returns>
 public IAsyncResult BeginListQueues(ListQueuesRequest listQueuesRequest, AsyncCallback callback, object state)
 {
     return invokeListQueues(listQueuesRequest, callback, state, false);
 }
        /// <summary>
        /// <para>Returns a list of your queues.</para>
        /// </summary>
        /// 
        /// <param name="listQueuesRequest">Container for the necessary parameters to execute the ListQueues service method on AmazonSQS.</param>
        /// 
        /// <returns>The response from the ListQueues service method, as returned by AmazonSQS.</returns>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<ListQueuesResponse> ListQueuesAsync(ListQueuesRequest listQueuesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new ListQueuesRequestMarshaller();
            var unmarshaller = ListQueuesResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, ListQueuesRequest, ListQueuesResponse>(listQueuesRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Example #34
0
        public ListQueuesResponse ListQueues(ListQueuesRequest request)
        {
            var urls = string.IsNullOrEmpty(request.QueueNamePrefix)
                ? queues.Keys
                : queues.Values
                    .Where(q => q.QueueDefinition
                        .QueueName.StartsWith(request.QueueNamePrefix, StringComparison.InvariantCultureIgnoreCase))
                    .Select(q => q.QueueDefinition.QueueUrl);

            var response = new ListQueuesResponse
            {
                QueueUrls = urls.ToList()
            };

            return response;
        }