Container for the parameters to the GetQueueUrl operation. Returns the URL of an existing queue. This action provides a simple way to retrieve the URL of an Amazon SQS queue.

To access a queue that belongs to another AWS account, use the QueueOwnerAWSAccountId parameter to specify the account ID of the queue's owner. The queue's owner must grant you permission to access the queue. For more information about shared queue access, see AddPermission or see Shared Queues in the Amazon SQS Developer Guide.

Inheritance: AmazonSQSRequest
Ejemplo n.º 1
0
 private static string GetQueueUrl(string queueName)
 {
     var request = new GetQueueUrlRequest(queueName);
     var response = _client.GetQueueUrl(request);
     if (response.HttpStatusCode != HttpStatusCode.OK) throw new Exception("Http error " + (int)response.HttpStatusCode);
     return response.QueueUrl;
 }
        public void Init(Address address, TransactionSettings transactionSettings, Func<TransportMessage, bool> tryProcessMessage, Action<TransportMessage, Exception> endProcessMessage)
        {
            var getQueueUrlRequest = new GetQueueUrlRequest(address.ToSqsQueueName(ConnectionConfiguration));
            GetQueueUrlResponse getQueueUrlResponse;
            try
            {
                getQueueUrlResponse = SqsClient.GetQueueUrl(getQueueUrlRequest);
            }
            catch (Exception ex)
            {
                Logger.Error("Exception thrown from GetQueueUrl.", ex);
                throw;
            }
            _queueUrl = getQueueUrlResponse.QueueUrl;

			if (_purgeOnStartup)
            {
                // SQS only allows purging a queue once every 60 seconds or so. 
                // If you try to purge a queue twice in relatively quick succession,
                // PurgeQueueInProgressException will be thrown. 
                // This will happen if you are trying to start an endpoint twice or more
                // in that time. 
                try
                {
                    SqsClient.PurgeQueue(_queueUrl);
                }
                catch (PurgeQueueInProgressException ex)
                {
                    Logger.Warn("Multiple queue purges within 60 seconds are not permitted by SQS.", ex);
                }
                catch (Exception ex)
                {
                    Logger.Error("Exception thrown from PurgeQueue.", ex);
                    throw;
                }
            }

            _tryProcessMessage = tryProcessMessage;
            _endProcessMessage = endProcessMessage;

			if (transactionSettings != null)
				_isTransactional = transactionSettings.IsTransactional;
			else
				_isTransactional = true;
        }
Ejemplo n.º 3
0
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SQS.Model.GetQueueUrlRequest();

            if (cmdletContext.QueueName != null)
            {
                request.QueueName = cmdletContext.QueueName;
            }
            if (cmdletContext.QueueOwnerAWSAccountId != null)
            {
                request.QueueOwnerAWSAccountId = cmdletContext.QueueOwnerAWSAccountId;
            }

            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);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The method opens the queue
        /// </summary>
        public bool OpenQueue(string queuename, int maxnumberofmessages, RegionEndpoint regionendpoint,String AWSAccessKey="", String AWSSecretKey="")
        {
            ClearErrorInfo();

            IsValid = false;

            if (!string.IsNullOrWhiteSpace(queuename))
            {
                if (!String.IsNullOrEmpty (AWSAccessKey))
                {
                    queue = AWSClientFactory.CreateAmazonSQSClient (AWSAccessKey, AWSSecretKey,regionendpoint);
                }
                else
                {
                    queue = AWSClientFactory.CreateAmazonSQSClient (regionendpoint);
                }
                try
                {
                    // Get queue url
                    GetQueueUrlRequest sqsRequest = new GetQueueUrlRequest();
                    sqsRequest.QueueName          = queuename;
                    queueurl                      = queue.GetQueueUrl(sqsRequest);

                    // Format receive messages request
                    rcvMessageRequest                     = new ReceiveMessageRequest();
                    rcvMessageRequest.QueueUrl            = queueurl.QueueUrl;
                    rcvMessageRequest.MaxNumberOfMessages = maxnumberofmessages;

                    // Format the delete messages request
                    delMessageRequest          = new DeleteMessageRequest();
                    delMessageRequest.QueueUrl = queueurl.QueueUrl;

                    IsValid = true;
                }
                catch (Exception ex)
                {
                    ErrorCode    = e_Exception;
                    ErrorMessage = ex.Message;
                }
            }

            return IsValid;
        }
Ejemplo n.º 5
0
        private string GetQueueUrl(string queue)
        {
            System.Net.WebException exception = null;

            int attempts = 0;
            while (attempts < 3)
            {
                try
                {
                    if (!queueUrls.ContainsKey(queue))
                    {
                        GetQueueUrlRequest request = new GetQueueUrlRequest();
                        request.QueueName = SanitiseQueueName(queue);
                        GetQueueUrlResponse response = client.GetQueueUrl(request);

                        queueUrls.Add(queue, response.GetQueueUrlResult.QueueUrl);
                    }

                    return queueUrls[queue];
                }
                catch (System.Net.WebException ex)
                {
                    exception = ex;
                }

                attempts++;
                System.Threading.Thread.Sleep(15); // give the remote server some time to recover
            }

            throw exception;
        }
Ejemplo n.º 6
0
    public static void SQSGetQueueUrl()
    {
      #region SQSGetQueueUrl
      var client = new AmazonSQSClient();

      var request = new GetQueueUrlRequest
      {
        QueueName = "MyTestQueue",
        QueueOwnerAWSAccountId = "80398EXAMPLE"
      };

      var response = client.GetQueueUrl(request);

      Console.WriteLine("Queue URL: " + response.QueueUrl);
      #endregion

      Console.ReadLine();
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueUrl operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS.GetQueueUrl"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl 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<GetQueueUrlResponse> GetQueueUrlAsync(GetQueueUrlRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, GetQueueUrlRequest, GetQueueUrlResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns the URL of an existing queue.       This action provides a simple way
        /// to retrieve the URL of an Amazon SQS queue.    
        /// 
        ///     
        /// <para>
        ///       To access a queue that belongs to another AWS account, use the <code>QueueOwnerAWSAccountId</code>
        ///      parameter to specify the account ID of the queue's owner. The queue's owner must
        /// grant you permission to       access the queue. For more information about shared
        /// queue access, see <a>AddPermission</a> or go to      <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html">Shared
        /// Queues</a>      in the <i>Amazon SQS Developer Guide</i>.    
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl service method.</param>
        /// 
        /// <returns>The response from the GetQueueUrl service method, as returned by SQS.</returns>
        /// <exception cref="QueueDoesNotExistException">
        /// The queue referred to does not exist.
        /// </exception>
        public GetQueueUrlResponse GetQueueUrl(GetQueueUrlRequest request)
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.Instance;

            return Invoke<GetQueueUrlRequest,GetQueueUrlResponse>(request, marshaller, unmarshaller);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueUrl operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl 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<GetQueueUrlResponse> GetQueueUrlAsync(GetQueueUrlRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.Instance;

            return InvokeAsync<GetQueueUrlRequest,GetQueueUrlResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Ejemplo n.º 10
0
 IAsyncResult invokeGetQueueUrl(GetQueueUrlRequest getQueueUrlRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new GetQueueUrlRequestMarshaller().Marshall(getQueueUrlRequest);
     var unmarshaller = GetQueueUrlResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
Ejemplo n.º 11
0
        public GetQueueUrlResponse GetQueueUrl(GetQueueUrlRequest request)
        {
            var q = queues.Where(kvp => kvp.Value.QueueDefinition.QueueName.Equals(request.QueueName, StringComparison.InvariantCultureIgnoreCase))
                .Select(kvp => kvp.Value)
                .SingleOrDefault();

            if (q == null)
                throw new QueueDoesNotExistException("Queue does not exist with namel [{0}]".Fmt(request.QueueName));

            return new GetQueueUrlResponse
            {
                QueueUrl = q.QueueDefinition.QueueUrl
            };
        }
Ejemplo n.º 12
0
 private Amazon.SQS.Model.GetQueueUrlResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.GetQueueUrlRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "GetQueueUrl");
     try
     {
         #if DESKTOP
         return(client.GetQueueUrl(request));
         #elif CORECLR
         return(client.GetQueueUrlAsync(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;
     }
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetQueueUrl operation.
 /// </summary>
 /// 
 /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl 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 GetQueueUrlAsync(GetQueueUrlRequest request, AmazonServiceCallback<GetQueueUrlRequest, GetQueueUrlResponse> callback, AsyncOptions options = null)
 {
     options = options == null?new AsyncOptions():options;
     var marshaller = new GetQueueUrlRequestMarshaller();
     var unmarshaller = GetQueueUrlResponseUnmarshaller.Instance;
     Action<AmazonWebServiceRequest, AmazonWebServiceResponse, Exception, AsyncOptions> callbackHelper = null;
     if(callback !=null )
         callbackHelper = (AmazonWebServiceRequest req, AmazonWebServiceResponse res, Exception ex, AsyncOptions ao) => { 
             AmazonServiceResult<GetQueueUrlRequest,GetQueueUrlResponse> responseObject 
                     = new AmazonServiceResult<GetQueueUrlRequest,GetQueueUrlResponse>((GetQueueUrlRequest)req, (GetQueueUrlResponse)res, ex , ao.State);    
                 callback(responseObject); 
         };
     BeginInvoke<GetQueueUrlRequest>(request, marshaller, unmarshaller, options, callbackHelper);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Returns the URL of an existing queue. This action provides a simple way to retrieve
 /// the URL of an Amazon SQS queue. 
 /// 
 ///  
 /// <para>
 ///  To access a queue that belongs to another AWS account, use the <code>QueueOwnerAWSAccountId</code>
 /// parameter to specify the account ID of the queue's owner. The queue's owner must grant
 /// you permission to access the queue. For more information about shared queue access,
 /// see <a>AddPermission</a> or go to <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html">Shared
 /// Queues</a> in the <i>Amazon SQS Developer Guide</i>. 
 /// </para>
 /// </summary>
 /// <param name="queueName">The name of the queue whose URL must be fetched. Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.</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>
 /// 
 /// <returns>The response from the GetQueueUrl service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
 /// The queue referred to does not exist.
 /// </exception>
 public void GetQueueUrlAsync(string queueName,  AmazonServiceCallback<GetQueueUrlRequest, GetQueueUrlResponse> callback, AsyncOptions options = null)
 {
     var request = new GetQueueUrlRequest();
     request.QueueName = queueName;
     GetQueueUrlAsync(request, callback, options);
 }
Ejemplo n.º 15
0
 public static bool GetQueueUrlRquestMatches(GetQueueUrlRequest request, string expectedQueueName)
 {
     return request.QueueName.Equals(expectedQueueName);
 }
Ejemplo n.º 16
0
 /// <summary>
 /// <para>The <c>GetQueueUrl</c> action returns the URL of an existing queue.</para>
 /// </summary>
 /// 
 /// <param name="getQueueUrlRequest">Container for the necessary parameters to execute the GetQueueUrl service method on AmazonSQS.</param>
 /// 
 /// <returns>The response from the GetQueueUrl service method, as returned by AmazonSQS.</returns>
 /// 
 /// <exception cref="QueueDoesNotExistException"/>
 public GetQueueUrlResponse GetQueueUrl(GetQueueUrlRequest getQueueUrlRequest)
 {
     IAsyncResult asyncResult = invokeGetQueueUrl(getQueueUrlRequest, null, null, true);
     return EndGetQueueUrl(asyncResult);
 }
Ejemplo n.º 17
0
 public Task<GetQueueUrlResponse> GetQueueUrlAsync(GetQueueUrlRequest request, CancellationToken cancellationToken = new CancellationToken())
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Initiates the asynchronous execution of the GetQueueUrl operation.
 /// <seealso cref="Amazon.SQS.IAmazonSQS.GetQueueUrl"/>
 /// </summary>
 /// 
 /// <param name="getQueueUrlRequest">Container for the necessary parameters to execute the GetQueueUrl 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 EndGetQueueUrl
 ///         operation.</returns>
 public IAsyncResult BeginGetQueueUrl(GetQueueUrlRequest getQueueUrlRequest, AsyncCallback callback, object state)
 {
     return invokeGetQueueUrl(getQueueUrlRequest, callback, state, false);
 }
Ejemplo n.º 19
0
        public IQueue GetQueueById(string queueId)
        {
            GetQueueUrlRequest request = new GetQueueUrlRequest()
                .WithQueueName(queueId);
            var response = _sqsClient.GetQueueUrl(request);

            return new AwsQueue(response.GetQueueUrlResult.QueueUrl);
        }
Ejemplo n.º 20
0
 /// <summary>
 /// Returns the URL of an existing queue. This action provides a simple way to retrieve
 /// the URL of an Amazon SQS queue.
 /// 
 ///  
 /// <para>
 /// To access a queue that belongs to another AWS account, use the <code>QueueOwnerAWSAccountId</code>
 /// parameter to specify the account ID of the queue's owner. The queue's owner must grant
 /// you permission to access the queue. For more information about shared queue access,
 /// see <code> <a>AddPermission</a> </code> or see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html">Shared
 /// Queues</a> in the <i>Amazon SQS Developer Guide</i>. 
 /// </para>
 /// </summary>
 /// <param name="queueName">The name of the queue whose URL must be fetched. Maximum 80 characters. Valid values: alphanumeric characters, hyphens (<code>-</code>), and underscores (<code>_</code>). 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 GetQueueUrl service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.QueueDoesNotExistException">
 /// The queue referred to doesn't exist.
 /// </exception>
 public Task<GetQueueUrlResponse> GetQueueUrlAsync(string queueName, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new GetQueueUrlRequest();
     request.QueueName = queueName;
     return GetQueueUrlAsync(request, cancellationToken);
 }
Ejemplo n.º 21
0
        public static void Main(string[] args)
        {
            const string QUEUENAME = "MyQueue";

            AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient();

            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 = QUEUENAME;
                CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest);
                String myQueueUrl;
                myQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl;

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

                var getQueueReq = new GetQueueUrlRequest();
                getQueueReq.QueueName = "AppZwitschern";
                var getQueueResp = sqs.GetQueueUrl(getQueueReq);
                Console.WriteLine(":: Url={0}", getQueueResp.GetQueueUrlResult.QueueUrl);

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

            Console.WriteLine("Press Enter to continue...");
            Console.Read();
        }
Ejemplo n.º 22
0
 /// <summary>
 /// Returns the URL of an existing queue.       This action provides a simple way
 /// to retrieve the URL of an Amazon SQS queue.    
 /// 
 ///     
 /// <para>
 ///       To access a queue that belongs to another AWS account, use the <code>QueueOwnerAWSAccountId</code>
 ///      parameter to specify the account ID of the queue's owner. The queue's owner must
 /// grant you permission to       access the queue. For more information about shared
 /// queue access, see <a>AddPermission</a> or go to      <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html">Shared
 /// Queues</a>      in the <i>Amazon SQS Developer Guide</i>.    
 /// </para>
 /// </summary>
 /// <param name="queueName">The name of the queue whose URL must be fetched.    Maximum 80 characters; alphanumeric characters, hyphens (-), and underscores (_) are allowed.</param>
 /// 
 /// <returns>The response from the GetQueueUrl service method, as returned by SQS.</returns>
 /// <exception cref="QueueDoesNotExistException">
 /// The queue referred to does not exist.
 /// </exception>
 public GetQueueUrlResponse GetQueueUrl(string queueName)
 {
     var request = new GetQueueUrlRequest();
     request.QueueName = queueName;
     return GetQueueUrl(request);
 }
Ejemplo n.º 23
0
		internal GetQueueUrlResponse GetQueueUrl(GetQueueUrlRequest request)
        {
            var task = GetQueueUrlAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
Ejemplo n.º 24
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueUrl operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl 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 EndGetQueueUrl
        ///         operation.</returns>
        public IAsyncResult BeginGetQueueUrl(GetQueueUrlRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.Instance;

            return BeginInvoke<GetQueueUrlRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Ejemplo n.º 25
0
        IAsyncResult invokeGetQueueUrl(GetQueueUrlRequest request, AsyncCallback callback, object state, bool synchronized)
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.Instance;

            return Invoke(request, callback, state, synchronized, marshaller, unmarshaller, signer);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// <para> Returns the URL of an existing queue. This action provides a simple way to retrieve the URL of an Amazon SQS queue. </para> <para> To
        /// access a queue that belongs to another AWS account, use the <c>QueueOwnerAWSAccountId</c> parameter to specify the account ID of the queue's
        /// owner. The queue's owner must grant you permission to access the queue. For more information about shared queue access, see AddPermission or
        /// go to <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/acp-overview.html">Shared Queues</a> in the
        /// <i>Amazon SQS Developer Guide</i> .
        /// </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueUrl service method on AmazonSQS.</param>
        /// 
        /// <returns>The response from the GetQueueUrl service method, as returned by AmazonSQS.</returns>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.QueueDoesNotExistException" />
		public GetQueueUrlResponse GetQueueUrl(GetQueueUrlRequest request)
        {
            var task = GetQueueUrlAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// The method opens the queue
        /// </summary>
        public bool OpenQueue(string queuename, int maxnumberofmessages, String AWSAccessKey, String AWSSecretKey)
        {
            ClearErrorInfo();

            IsValid = false;

            if (!string.IsNullOrWhiteSpace(queuename))
            {
                // Checking for the need to use provided credentials instead of reading from app.Config
                if (!String.IsNullOrWhiteSpace(AWSSecretKey) && !String.IsNullOrWhiteSpace(AWSSecretKey))
                {
                    AWSCredentials awsCredentials = new BasicAWSCredentials(AWSAccessKey, AWSSecretKey);
                    queue                         = AWSClientFactory.CreateAmazonSQSClient (awsCredentials, RegionEndpoint.USEast1);
                }
                else
                {
                    queue = AWSClientFactory.CreateAmazonSQSClient (RegionEndpoint.USEast1);
                }

                try
                {
                    // Get queue url
                    GetQueueUrlRequest sqsRequest = new GetQueueUrlRequest();
                    sqsRequest.QueueName          = queuename;
                    queueurl                      = queue.GetQueueUrl(sqsRequest);

                    // Format receive messages request
                    rcvMessageRequest                     = new ReceiveMessageRequest();
                    rcvMessageRequest.QueueUrl            = queueurl.QueueUrl;
                    rcvMessageRequest.MaxNumberOfMessages = maxnumberofmessages;

                    // Format the delete messages request
                    delMessageRequest          = new DeleteMessageRequest();
                    delMessageRequest.QueueUrl = queueurl.QueueUrl;

                    IsValid = true;
                }
                catch (Exception ex)
                {
                    ErrorCode = e_Exception;
                    ErrorMessage = ex.Message;
                }
            }

            return IsValid;
        }
Ejemplo n.º 28
0
        /// <summary>
        /// <para>The <c>GetQueueUrl</c> action returns the URL of an existing queue.</para>
        /// </summary>
        /// 
        /// <param name="getQueueUrlRequest">Container for the necessary parameters to execute the GetQueueUrl service method on AmazonSQS.</param>
        /// 
        /// <returns>The response from the GetQueueUrl service method, as returned by AmazonSQS.</returns>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.QueueDoesNotExistException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<GetQueueUrlResponse> GetQueueUrlAsync(GetQueueUrlRequest getQueueUrlRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueUrlRequestMarshaller();
            var unmarshaller = GetQueueUrlResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetQueueUrlRequest, GetQueueUrlResponse>(getQueueUrlRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
Ejemplo n.º 29
0
        public override bool QueueExists(string queue)
        {
            try
            {
                GetQueueUrlRequest request = new GetQueueUrlRequest();
                request.QueueName = SanitiseQueueName(queue);
                GetQueueUrlResponse response = client.GetQueueUrl(request);

                return true;
            }
            catch (AmazonSQSException)
            {
                return false;
            }
        }