public async Task <GetQueueAttributesResponse> GetQueueAttributesAsync(string queueUrl,
                                                                               CancellationToken cancellationToken = default)
        {
            this.Logger.LogDebug($"[{nameof(this.GetQueueAttributesAsync)}]");

            this.Logger.LogTrace(JsonConvert.SerializeObject(new { queueUrl }));

            if (string.IsNullOrWhiteSpace(queueUrl))
            {
                throw new ArgumentNullException(nameof(queueUrl));
            }

            var request = new Amazon.SQS.Model.GetQueueAttributesRequest
            {
                QueueUrl       = queueUrl,
                AttributeNames = new List <string>()
                {
                    Text.All
                },
            };

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: request));

            var response = await this.Repository.GetQueueAttributesAsync(request : request,
                                                                         cancellationToken : cancellationToken == default?this.CancellationToken.Token : cancellationToken);

            this.Logger.LogTrace(JsonConvert.SerializeObject(value: response));

            return(response);
        }
        private async Task<int> GetSqsCount()
        {
            var url = queueClient.GetQueueUrl(queueName);
            var request = new GetQueueAttributesRequest { QueueUrl = url.QueueUrl };
            request.AttributeNames.Add("ApproximateNumberOfMessages");
            request.AttributeNames.Add("ApproximateNumberOfMessagesNotVisible");

            var response = await queueClient.GetQueueAttributesAsync(request);
            return response == null ? 0 : response.ApproximateNumberOfMessages + response.ApproximateNumberOfMessagesNotVisible;
        }
Beispiel #3
0
        protected GetQueueAttributesResult GetAttrs(IEnumerable<string> attrKeys)
        {
            var request = new GetQueueAttributesRequest { 
                QueueUrl = Url,
                AttributeNames = new List<string>(attrKeys)
            };
            
            var result = Client.GetQueueAttributes(request);

            return result;
        }
        /// <summary>
        /// 
        /// Gets one or all attributes of a queue. Queues currently have two attributes you can get: ApproximateNumberOfMessages and VisibilityTimeout.
        /// 
        /// </summary>
        /// <param name="service">Instance of AmazonSQS service</param>
        /// <param name="request">GetQueueAttributesRequest request</param>
        public static void InvokeGetQueueAttributes(AmazonSQS service, GetQueueAttributesRequest request)
        {
            try 
            {
                GetQueueAttributesResponse response = service.GetQueueAttributes(request);
                
                
                Console.WriteLine ("Service Response");
                Console.WriteLine ("=============================================================================");
                Console.WriteLine ();

                Console.WriteLine("        GetQueueAttributesResponse");
                if (response.IsSetGetQueueAttributesResult()) 
                {
                    Console.WriteLine("            GetQueueAttributesResult");
                    GetQueueAttributesResult  getQueueAttributesResult = response.GetQueueAttributesResult;
                    List<Attribute> attributeList = getQueueAttributesResult.Attribute;
                    foreach (Attribute attribute in attributeList) 
                    {
                        Console.WriteLine("                Attribute");
                        if (attribute.IsSetName()) 
                        {
                            Console.WriteLine("                    Name");
                            Console.WriteLine("                        {0}", attribute.Name);
                        }
                        if (attribute.IsSetValue()) 
                        {
                            Console.WriteLine("                    Value");
                            Console.WriteLine("                        {0}", attribute.Value);
                        }
                    }
                } 
                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 static int Count(string queue_url)
 {
     AmazonSQS sqs = AWSClientFactory.CreateAmazonSQSClient();
     GetQueueAttributesRequest gqreq = new GetQueueAttributesRequest();
     gqreq.QueueUrl = queue_url;
     List<string> attr = new List<string>();
     attr.Add("All");
     gqreq.AttributeName = attr;
     GetQueueAttributesResponse gqres = sqs.GetQueueAttributes(gqreq);
     GetQueueAttributesResult gqrst = gqres.GetQueueAttributesResult;
     //Console.WriteLine("Invisible Messages:" + gqrst.ApproximateNumberOfMessagesNotVisible.ToString());
     //Console.WriteLine("Messages:" + gqrst.ApproximateNumberOfMessages);
     return gqrst.ApproximateNumberOfMessages;
 }
        public void subscribe_to_topic()
        {
            var getArnRequest = new GetQueueAttributesRequest().WithQueueUrl(_queueUrl).WithAttributeName("QueueArn");
            var clientArn = _client.GetQueueAttributes(getArnRequest).GetQueueAttributesResult.Attribute[0].Value;

            var sns = Amazon.AWSClientFactory.CreateAmazonSNSClient("AKIAIN2KJH4QJIUV7CGQ",
                                                                    "18ypN0y7SGA+L0XDVMHm9lBVmQ2oF2bdm7CGIijA");

            var subscriptionRequest = new SubscribeRequest()
                .WithEndpoint(clientArn)
                .WithProtocol("sqs")
                .WithTopicArn("arn:aws:sns:us-east-1:451419498740:EventMessage");
            
            var response = sns.Subscribe(subscriptionRequest);
            Console.WriteLine(response.SubscribeResult.SubscriptionArn);
        }
        public void Subscribe()
        {
            SetPermissions();
            var getArnRequest = new GetQueueAttributesRequest().WithQueueUrl(_config.SqsQueueUrl).WithAttributeName("QueueArn");
            var clientArn = _client.GetQueueAttributes(getArnRequest).GetQueueAttributesResult.Attribute[0].Value;

            var sns = AWSClientFactory.CreateAmazonSNSClient(_config.AccessKeyId,
                                                                    _config.SecretKey);

            var subscriptionRequest = new SubscribeRequest()
                .WithEndpoint(clientArn)
                .WithProtocol("sqs")
                .WithTopicArn(_config.TopicAccessResourceName);

            sns.Subscribe(subscriptionRequest);
        }
        public object Execute(ExecutorContext context)
        {
            var cmdletContext = context as CmdletContext;
            // create request
            var request = new Amazon.SQS.Model.GetQueueAttributesRequest();

            if (cmdletContext.AttributeName != null)
            {
                request.AttributeNames = cmdletContext.AttributeName;
            }
            if (cmdletContext.QueueUrl != null)
            {
                request.QueueUrl = cmdletContext.QueueUrl;
            }

            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 ISubscribeReponseMessage Subscribe(string queueUrl)
        {
            var sqsConfig = new AmazonSQSConfig {ServiceURL = SqsServiceUrl};
            var snsConfig = new AmazonSimpleNotificationServiceConfig {ServiceURL = SnsServiceUrl};

            using (var sqsClient = _awsConfig.CreateAwsClient<AmazonSQSClient>(sqsConfig))
            {
                var attributesRequest = new GetQueueAttributesRequest(queueUrl, new List<string> {"QueueArn"});

                var attributesResponse = sqsClient.GetQueueAttributes(attributesRequest);

                using (var snsClient = _awsConfig.CreateAwsClient<AmazonSimpleNotificationServiceClient>(snsConfig))
                {
                    var subribeResonse =
                        snsClient.Subscribe(new SubscribeRequest(TopicArn, "sqs", attributesResponse.QueueARN));
                }

                var actions = new ActionIdentifier[2];
                actions[0] = SQSActionIdentifiers.SendMessage;
                actions[1] = SQSActionIdentifiers.ReceiveMessage;
                var sqsPolicy =
                    new Policy().WithStatements(
                        new Statement(Statement.StatementEffect.Allow).WithPrincipals(Principal.AllUsers)
                            .WithResources(
                                new Resource(attributesResponse.QueueARN))
                            .WithConditions(
                                ConditionFactory.NewSourceArnCondition(
                                    TopicArn))
                            .WithActionIdentifiers(actions));
                var setQueueAttributesRequest = new SetQueueAttributesRequest();

                var attributes = new Dictionary<string, string> {{"Policy", sqsPolicy.ToJson()}};
                var attRequest = new SetQueueAttributesRequest(attributesRequest.QueueUrl, attributes);

                sqsClient.SetQueueAttributes(attRequest);

                return new SubcriptionMessage("Ok");
            }
        }
Beispiel #10
0
        public void create_sqs_queue()
        {
            GetUserNameAndPassword();
            var sqsClient = Amazon.AWSClientFactory.CreateAmazonSQSClient(_key, _secret);
            var snsTopic = Amazon.AWSClientFactory.CreateAmazonSNSClient(_key, _secret);
            var topicArn = "arn:aws:sns:us-east-1:451419498740:Elliott-has-an-awesome-blog";
            //Create a new SQS queue
            var createQueueRequest = new CreateQueueRequest().WithQueueName("elliotts-blog");
            var createQueueResponse = sqsClient.CreateQueue(createQueueRequest);
            // keep the queueUrl handy
            var queueUrl = createQueueResponse.CreateQueueResult.QueueUrl;
            // get the Access Resource Name so we can allow the SNS to put messages on it
            var getQueueArnRequest = new GetQueueAttributesRequest()
                .WithQueueUrl(queueUrl)
                .WithAttributeName("QueueArn");
            var getQueueArnResponse = sqsClient.GetQueueAttributes(getQueueArnRequest);
            var queueArn = getQueueArnResponse.GetQueueAttributesResult.Attribute[0].Value;

            //create a Policy for the SQS queue that allows SNS to publish to it
            var allowSnsStatement = new Statement(Statement.StatementEffect.Allow)
                .WithPrincipals(Principal.AllUsers)
                .WithResources(new Resource(queueArn))
                .WithConditions(ConditionFactory.NewSourceArnCondition(topicArn))
                .WithActionIdentifiers(SQSActionIdentifiers.SendMessage);
            var policy = new Policy("allow sns").WithStatements(new[] {allowSnsStatement});
            var attribute = new Attribute().WithName("Policy").WithValue(policy.ToJson());
            var setQueueAttributesRequest =
                new SetQueueAttributesRequest().WithQueueUrl(queueUrl).WithAttribute(attribute);
            sqsClient.SetQueueAttributes(setQueueAttributesRequest);

            // ok, now lets create the subscription for sqs with the queueArn we created
            var subscribeRequest = new SubscribeRequest()
                .WithEndpoint(queueArn)
                .WithTopicArn(topicArn)
                .WithProtocol("sqs");

            snsTopic.Subscribe(subscribeRequest);
        }
 /// <summary>
 /// Gets attributes for the specified queue. The following attributes are supported: 
 ///     <ul>        <li><code>All</code> - returns all values.</li>        <li><code>ApproximateNumberOfMessages</code>
 /// - returns the approximate          number of visible messages in a queue. For more
 /// information, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources
 /// Required to Process Messages</a>          in the <i>Amazon SQS Developer Guide</i>.</li>
 ///        <li><code>ApproximateNumberOfMessagesNotVisible</code> - returns the      
 ///    approximate number of messages that are not timed-out and not deleted.        
 ///   For more information, see           <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources
 /// Required to Process Messages</a> in the          <i>Amazon SQS Developer Guide</i>.</li>
 ///        <li><code>VisibilityTimeout</code> - returns the visibility timeout for   
 ///       the queue. For more information about visibility timeout, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">Visibility
 /// Timeout</a> in the <i>Amazon SQS Developer Guide</i>.</li>        <li><code>CreatedTimestamp</code>
 /// - returns the time when the queue was          created (epoch time in seconds).</li>
 ///        <li><code>LastModifiedTimestamp</code> - returns the time when the queue  
 ///        was last changed (epoch time in seconds).</li>        <li><code>Policy</code>
 /// - returns the queue's policy.</li>        <li><code>MaximumMessageSize</code> - returns
 /// the limit of how many bytes          a message can contain before Amazon SQS rejects
 /// it.</li>        <li><code>MessageRetentionPeriod</code> - returns the number of seconds
 ///          Amazon SQS retains a message.</li>        <li><code>QueueArn</code> - returns
 /// the queue's Amazon resource name          (ARN).</li>        <li><code>ApproximateNumberOfMessagesDelayed</code>
 /// - returns the          approximate number of messages that are pending to be added
 /// to the          queue.</li>        <li><code>DelaySeconds</code> - returns the default
 /// delay on the queue          in seconds.</li>        <li><code>ReceiveMessageWaitTimeSeconds</code>
 /// - returns the time for which a        ReceiveMessage call will wait for a message
 /// to arrive.</li>        <li><code>RedrivePolicy</code> - returns the parameters for
 /// dead letter queue functionality of the source queue.           For more information
 /// about RedrivePolicy and dead letter queues, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html">Using
 /// Amazon SQS Dead Letter Queues</a> in the <i>Amazon SQS Developer Guide</i>.</li> 
 ///     </ul>     
 /// 
 ///     <note>Going forward, new attributes might be added.       If you are writing code
 /// that calls this action, we recommend that you structure your code so that it can handle
 /// new attributes gracefully.</note>    <note>Some API actions take lists of parameters.
 /// These lists are specified using the <code>param.n</code> notation. Values      of
 /// <code>n</code> are integers starting from 1. For example, a parameter list with two
 /// elements looks like this:     </note>    
 /// <para>
 /// <code>&amp;Attribute.1=this</code>
 /// </para>
 ///     
 /// <para>
 /// <code>&amp;Attribute.2=that</code>
 /// </para>
 /// </summary>
 /// <param name="queueUrl">The URL of the Amazon SQS queue to take action on.</param>
 /// <param name="attributeNames">A list of attributes to retrieve information for. </param>
 /// 
 /// <returns>The response from the GetQueueAttributes service method, as returned by SQS.</returns>
 /// <exception cref="InvalidAttributeNameException">
 /// The attribute referred to does not exist.
 /// </exception>
 public GetQueueAttributesResponse GetQueueAttributes(string queueUrl, List<string> attributeNames)
 {
     var request = new GetQueueAttributesRequest();
     request.QueueUrl = queueUrl;
     request.AttributeNames = attributeNames;
     return GetQueueAttributes(request);
 }
        /// <summary>
        /// Gets attributes for the specified queue. The following attributes are supported: 
        ///     <ul>        <li><code>All</code> - returns all values.</li>        <li><code>ApproximateNumberOfMessages</code>
        /// - returns the approximate          number of visible messages in a queue. For more
        /// information, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources
        /// Required to Process Messages</a>          in the <i>Amazon SQS Developer Guide</i>.</li>
        ///        <li><code>ApproximateNumberOfMessagesNotVisible</code> - returns the      
        ///    approximate number of messages that are not timed-out and not deleted.        
        ///   For more information, see           <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources
        /// Required to Process Messages</a> in the          <i>Amazon SQS Developer Guide</i>.</li>
        ///        <li><code>VisibilityTimeout</code> - returns the visibility timeout for   
        ///       the queue. For more information about visibility timeout, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">Visibility
        /// Timeout</a> in the <i>Amazon SQS Developer Guide</i>.</li>        <li><code>CreatedTimestamp</code>
        /// - returns the time when the queue was          created (epoch time in seconds).</li>
        ///        <li><code>LastModifiedTimestamp</code> - returns the time when the queue  
        ///        was last changed (epoch time in seconds).</li>        <li><code>Policy</code>
        /// - returns the queue's policy.</li>        <li><code>MaximumMessageSize</code> - returns
        /// the limit of how many bytes          a message can contain before Amazon SQS rejects
        /// it.</li>        <li><code>MessageRetentionPeriod</code> - returns the number of seconds
        ///          Amazon SQS retains a message.</li>        <li><code>QueueArn</code> - returns
        /// the queue's Amazon resource name          (ARN).</li>        <li><code>ApproximateNumberOfMessagesDelayed</code>
        /// - returns the          approximate number of messages that are pending to be added
        /// to the          queue.</li>        <li><code>DelaySeconds</code> - returns the default
        /// delay on the queue          in seconds.</li>        <li><code>ReceiveMessageWaitTimeSeconds</code>
        /// - returns the time for which a        ReceiveMessage call will wait for a message
        /// to arrive.</li>        <li><code>RedrivePolicy</code> - returns the parameters for
        /// dead letter queue functionality of the source queue.           For more information
        /// about RedrivePolicy and dead letter queues, see          <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html">Using
        /// Amazon SQS Dead Letter Queues</a> in the <i>Amazon SQS Developer Guide</i>.</li> 
        ///     </ul>     
        /// 
        ///     <note>Going forward, new attributes might be added.       If you are writing code
        /// that calls this action, we recommend that you structure your code so that it can handle
        /// new attributes gracefully.</note>    <note>Some API actions take lists of parameters.
        /// These lists are specified using the <code>param.n</code> notation. Values      of
        /// <code>n</code> are integers starting from 1. For example, a parameter list with two
        /// elements looks like this:     </note>    
        /// <para>
        /// <code>&amp;Attribute.1=this</code>
        /// </para>
        ///     
        /// <para>
        /// <code>&amp;Attribute.2=that</code>
        /// </para>
        /// </summary>
        /// <param name="request">Container for the necessary parameters to execute the GetQueueAttributes service method.</param>
        /// 
        /// <returns>The response from the GetQueueAttributes service method, as returned by SQS.</returns>
        /// <exception cref="InvalidAttributeNameException">
        /// The attribute referred to does not exist.
        /// </exception>
        public GetQueueAttributesResponse GetQueueAttributes(GetQueueAttributesRequest request)
        {
            var marshaller = new GetQueueAttributesRequestMarshaller();
            var unmarshaller = GetQueueAttributesResponseUnmarshaller.Instance;

            return Invoke<GetQueueAttributesRequest,GetQueueAttributesResponse>(request, marshaller, unmarshaller);
        }
Beispiel #13
0
 /// <summary>
 /// Gets attributes for the specified queue.
 /// 
 ///  <note> 
 /// <para>
 /// Some actions take lists of parameters. These lists are specified using the <code>param.n</code>
 /// notation. Values of <code>n</code> are integers starting from 1. For example, a parameter
 /// list with two elements looks like this:
 /// </para>
 ///  
 /// <para>
 ///  <code>&amp;Attribute.1=this</code> 
 /// </para>
 ///  
 /// <para>
 ///  <code>&amp;Attribute.2=that</code> 
 /// </para>
 ///  </note>
 /// </summary>
 /// <param name="queueUrl">The URL of the Amazon SQS queue whose attribute information is retrieved. Queue URLs are case-sensitive.</param>
 /// <param name="attributeNames">A list of attributes for which to retrieve information. <note> In the future, new attributes might be added. If you write code that calls this action, we recommend that you structure your code so that it can handle new attributes gracefully. </note> The following attributes are supported: <ul> <li>  <code>All</code> - Returns all values.  </li> <li>  <code>ApproximateNumberOfMessages</code> - Returns the approximate number of visible messages in a queue. For more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-resources-required-process-messages.html">Resources Required to Process Messages</a> in the <i>Amazon SQS Developer Guide</i>.  </li> <li>  <code>ApproximateNumberOfMessagesDelayed</code> - Returns the approximate number of messages that are waiting to be added to the queue.  </li> <li>  <code>ApproximateNumberOfMessagesNotVisible</code> - Returns the approximate number of messages that have not timed-out and aren't deleted. For more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-resources-required-process-messages.html">Resources Required to Process Messages</a> in the <i>Amazon SQS Developer Guide</i>.  </li> <li>  <code>CreatedTimestamp</code> - Returns the time when the queue was created in seconds (<a href="http://en.wikipedia.org/wiki/Unix_time">epoch time</a>). </li> <li>  <code>DelaySeconds</code> - Returns the default delay on the queue in seconds. </li> <li>  <code>LastModifiedTimestamp</code> - Returns the time when the queue was last changed in seconds (<a href="http://en.wikipedia.org/wiki/Unix_time">epoch time</a>). </li> <li>  <code>MaximumMessageSize</code> - Returns the limit of how many bytes a message can contain before Amazon SQS rejects it. </li> <li>  <code>MessageRetentionPeriod</code> - Returns the number of seconds for which Amazon SQS retains a message. </li> <li>  <code>Policy</code> - Returns the policy of the queue. </li> <li>  <code>QueueArn</code> - Returns the Amazon resource name (ARN) of the queue. </li> <li>  <code>ReceiveMessageWaitTimeSeconds</code> - Returns the number of seconds for which the <code>ReceiveMessage</code> action waits for a message to arrive.  </li> <li>  <code>RedrivePolicy</code> - Returns the parameters for dead letter queue functionality of the source queue. For more information about the redrive policy and dead letter queues, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html">Using Amazon SQS Dead Letter Queues</a> in the <i>Amazon SQS Developer Guide</i>.  </li> <li>  <code>VisibilityTimeout</code> - Returns the visibility timeout for the queue. For more information about the visibility timeout, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html">Visibility Timeout</a> in the <i>Amazon SQS Developer Guide</i>.  </li> </ul> The following attributes apply only to <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html">FIFO (first-in-first-out) queues</a>: <ul> <li>  <code>FifoQueue</code> - Returns whether the queue is FIFO. For more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic">FIFO Queue Logic</a> in the <i>Amazon SQS Developer Guide</i>. </li> <li>  <code>ContentBasedDeduplication</code> - Returns whether content-based deduplication is enabled for the queue. For more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing">Exactly-Once Processing</a> in the <i>Amazon SQS Developer Guide</i>.  </li> </ul></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 GetQueueAttributes service method, as returned by SQS.</returns>
 /// <exception cref="Amazon.SQS.Model.InvalidAttributeNameException">
 /// The attribute referred to doesn't exist.
 /// </exception>
 public Task<GetQueueAttributesResponse> GetQueueAttributesAsync(string queueUrl, List<string> attributeNames, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
 {
     var request = new GetQueueAttributesRequest();
     request.QueueUrl = queueUrl;
     request.AttributeNames = attributeNames;
     return GetQueueAttributesAsync(request, cancellationToken);
 }
Beispiel #14
0
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueAttributes operation.
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueAttributes 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<GetQueueAttributesResponse> GetQueueAttributesAsync(GetQueueAttributesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueAttributesRequestMarshaller();
            var unmarshaller = GetQueueAttributesResponseUnmarshaller.Instance;

            return InvokeAsync<GetQueueAttributesRequest,GetQueueAttributesResponse>(request, marshaller, 
                unmarshaller, cancellationToken);
        }
Beispiel #15
0
        /// <summary>
        /// Callback for windowing the SQS messages ordered by time queued
        /// </summary>
        /// <param name="state"></param>
        private void WindowCallback(Object state)
        {
            try
            {
                CancellationToken ct = (CancellationToken)state;
                List<Message> messages = new List<Message>();

                // syncronize the processing of windows
                if ((!ct.IsCancellationRequested) &
                    (Monitor.TryEnter(_windowLock, 1000)))
                {
                    try
                    {
                        long epochWindowTime = ToEpochTimeInMilliseconds(DateTime.UtcNow.Subtract(this.SQSWindow));
                        int numberOfMessages = 0;

                        // 1st query to determine the # of Messages available in the queue
                        using (AmazonSQSClient client = new AmazonSQSClient(
                            this.AWSAccessKey, this.AWSSecretAccessKey,
                            new AmazonSQSConfig() { ServiceURL = this.AWSSQSServiceUrl }))
                        {
                            // get the NumberOfMessages to optimize how to Receive all of the messages from the queue
                            GetQueueAttributesRequest attributesRequest = new GetQueueAttributesRequest();
                            attributesRequest.QueueUrl = this.QueueUrl;
                            attributesRequest.AttributeName.Add("ApproximateNumberOfMessages");
                            numberOfMessages = client.GetQueueAttributes(attributesRequest).GetQueueAttributesResult.ApproximateNumberOfMessages;
                        }

                        // determine if we need to Receive messages from the Queue
                        if (numberOfMessages > 0)
                        {
                            if (numberOfMessages < 10)
                            {
                                // just do it inline it's less expensive than spinning threads
                                ReceiveTask(ct, numberOfMessages);
                            }
                            else
                            {
                                // use the default partitioner to determine the number of tasks
                                // TODO Create a custom partitioner that takes into account the batch x 10 of SQS
                                Parallel.ForEach(Partitioner.Create(0, numberOfMessages),
                                    (range) => ReceiveTask(ct, range.Item2 - range.Item1));
                            }
                        }

                        // ok so all messages have been Receieved and ordered or no more messages can be popped
                        if (!ct.IsCancellationRequested)
                        {
                            // get all messages less than the window time from the rb tree
                            // probably don't have to lock on _setLock because of the _windowLock but let's be safe
                            lock (_setLock)
                            {
                                messages.AddRange(_set.Where((m) => long.Parse(m.Attribute[0].Value) < epochWindowTime));
                                _set.RemoveWhere((m) => long.Parse(m.Attribute[0].Value) < epochWindowTime);
                            }

                            // remove duplicates
                            //TODO Find a better way to dedup that doesn't destroy the order of the array
                            IEnumerable<Message> dedupMessages = messages.Distinct(new MessageEqualityComparer());

                            // distinct doesn't presever order so we need to reorder the window
                            IEnumerable<Message> orderedMessages = dedupMessages.OrderBy(m => m, new MessageSentTimeStampComparer());

                            // raise the WindowEvent with the results
                            if (!ct.IsCancellationRequested)
                            {
                                OnNewWindow(dedupMessages);
                            }
                        }

                    }
                    finally
                    {
                        Monitor.Exit(_windowLock);
                    }
                }

                // check if we should delete the messages
                if ((!ct.IsCancellationRequested) &
                    (messages.Count > 0))
                {
                    if (messages.Count < 10)
                    {
                        DeleteTask(ct, messages, new Tuple<int, int>(0, messages.Count));
                    }
                    else
                    {
                        // use the default partitioner to determine the number of tasks
                        // TODO Create a custom partitioner that takes into account the batch x 10 of SQS
                        Parallel.ForEach(Partitioner.Create(0, messages.Count),
                            (range) => DeleteTask(ct, messages, range));
                    }
                }
            }
            catch (Exception ex)
            {
                EventLog.WriteEntry(this.GetType().Name,
                    ex.Message + "\n" + ex.StackTrace,
                    EventLogEntryType.Error);
            }
        }
 IAsyncResult invokeGetQueueAttributes(GetQueueAttributesRequest getQueueAttributesRequest, AsyncCallback callback, object state, bool synchronized)
 {
     IRequest irequest = new GetQueueAttributesRequestMarshaller().Marshall(getQueueAttributesRequest);
     var unmarshaller = GetQueueAttributesResponseUnmarshaller.GetInstance();
     AsyncResult result = new AsyncResult(irequest, callback, state, synchronized, signer, unmarshaller);
     Invoke(result);
     return result;
 }
        public virtual string GetQueueArn(AmazonSQSClient sqsClient, string queueUrl)
        {
            string queueArn;
            // Construct a GetQueueAttributesRequest for the URL to retrieve the ARN
            var getQueueAttributesRequest = new GetQueueAttributesRequest
            {
                QueueUrl = queueUrl,
                AttributeNames =
                {
                    "QueueArn"
                }
            };

            // Submit the request
            GetQueueAttributesResponse getQueueAttributesResponse =
                sqsClient.GetQueueAttributes(getQueueAttributesRequest);

            // Add the discovered ARN to the queueArnList variable.
            queueArn = getQueueAttributesResponse.QueueARN;
            return queueArn;
        }
        public void Test_GetQueueAttributes_With_NonExisting_Attribute_And_Check_For_Error_Response()
        {
            bool hasCallbackArrived = false;
            string actualValue = string.Empty;
            string expectedValue = "InvalidAttributeName";
            string nonExistingAttribute = "poiu";

            SQSResponseEventHandler<object, ResponseEventArgs> handler = null;

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

                hasCallbackArrived = true;
            };

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

            //Create request object.
            GetQueueAttributesRequest request = new GetQueueAttributesRequest();
            request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting);
            request.AttributeName.Add(nonExistingAttribute);
            _client.GetQueueAttributes(request);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
		internal GetQueueAttributesResponse GetQueueAttributes(GetQueueAttributesRequest request)
        {
            var task = GetQueueAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                throw e.InnerException;
            }
        }
 public string GetQueueArn(Uri queueUrl)
 {
     // get queueArn
     var attributeRequest =
         new GetQueueAttributesRequest().WithQueueUrl(queueUrl.AbsoluteUri).WithAttributeName(
             queueArnAttributeName);
     using (var sqs = amazonSqsFactory())
     {
         var queueAttributes = sqs.GetQueueAttributes(attributeRequest);
         return queueAttributes.GetQueueAttributesResult.Attribute[0].Value;
     }
 }
Beispiel #21
0
 private static string GetQueueArn(string queueUrl)
 {
     var request = new GetQueueAttributesRequest(queueUrl, new List<string> { "QueueArn" });
     var response = _client.GetQueueAttributes(request);
     return response.QueueARN;
 }
Beispiel #22
0
        public void PopulateQueueAttributes(QueueDescription queue)
        {
            var req = new GetQueueAttributesRequest() {
                QueueUrl = queue.Url
            };

            req.AttributeName.Add("ApproximateNumberOfMessages");
            req.AttributeName.Add("MessageRetentionPeriod");

            var response = client.GetQueueAttributes(req);
            var result = new Dictionary<string, string>(10);
            if (response.IsSetGetQueueAttributesResult() && response.GetQueueAttributesResult.IsSetAttribute()) {
                foreach (Amazon.SQS.Model.Attribute att in response.GetQueueAttributesResult.Attribute) {
                    switch (att.Name) {
                        case "MessageRetentionPeriod":
                            queue.MessageRetentionPeriod = TimeSpan.FromSeconds(Double.Parse(att.Value));
                            break;
                        case "ApproximateNumberOfMessages":
                            queue.ApproximateNumberOfMessages = Int32.Parse(att.Value);
                            break;
                    }
                }
            }
        }
		/// <summary>
		/// Returns the count of items in the SQS
		/// </summary>
		private int GetSQSCount()
		{
			try
			{
				var AttribRequest = new GetQueueAttributesRequest
				{
					QueueUrl = Config.Default.AWSSQSQueueUrl,
					AttributeNames = new List<string>
					{
						"ApproximateNumberOfMessages"
					}
				};

				var AttribResponse = SqsClient.GetQueueAttributes(AttribRequest);
				return AttribResponse.ApproximateNumberOfMessages;
			}
			catch (Exception Ex)
			{
				CrashReporterProcessServicer.WriteException("GetSQSCount: " + Ex.ToString());
			}
			return 0;
		}
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueAttributes operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueAttributes 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 EndGetQueueAttributes
        ///         operation.</returns>
        public IAsyncResult BeginGetQueueAttributes(GetQueueAttributesRequest request, AsyncCallback callback, object state)
        {
            var marshaller = new GetQueueAttributesRequestMarshaller();
            var unmarshaller = GetQueueAttributesResponseUnmarshaller.Instance;

            return BeginInvoke<GetQueueAttributesRequest>(request, marshaller, unmarshaller,
                callback, state);
        }
Beispiel #25
0
        /// <summary>
        /// <para>Gets attributes for the specified queue. The following attributes are supported:
        /// <ul>
        /// <li> <c>All</c> - returns all values.</li>
        /// <li> <c>ApproximateNumberOfMessages</c> - returns the approximate number of visible messages in a queue. For more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources Required to Process
        /// Messages</a> in the <i>Amazon SQS Developer Guide</i> .</li>
        /// <li> <c>ApproximateNumberOfMessagesNotVisible</c> - returns the approximate number of messages that are not timed-out and not deleted. For
        /// more information, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ApproximateNumber.html">Resources
        /// Required to Process Messages</a> in the <i>Amazon SQS Developer Guide</i> .</li>
        /// <li> <c>VisibilityTimeout</c> - returns the visibility timeout for the queue. For more information about visibility timeout, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/AboutVT.html">Visibility Timeout</a> in the <i>Amazon SQS
        /// Developer Guide</i> .</li>
        /// <li> <c>CreatedTimestamp</c> - returns the time when the queue was created (epoch time in seconds).</li>
        /// <li> <c>LastModifiedTimestamp</c> - returns the time when the queue was last changed (epoch time in seconds).</li>
        /// <li> <c>Policy</c> - returns the queue's policy.</li>
        /// <li> <c>MaximumMessageSize</c> - returns the limit of how many bytes a message can contain before Amazon SQS rejects it.</li>
        /// <li> <c>MessageRetentionPeriod</c> - returns the number of seconds Amazon SQS retains a message.</li>
        /// <li> <c>QueueArn</c> - returns the queue's Amazon resource name (ARN).</li>
        /// <li> <c>ApproximateNumberOfMessagesDelayed</c> - returns the approximate number of messages that are pending to be added to the queue.</li>
        /// <li> <c>DelaySeconds</c> - returns the default delay on the queue in seconds.</li>
        /// <li> <c>ReceiveMessageWaitTimeSeconds</c> - returns the time for which a ReceiveMessage call will wait for a message to arrive.</li>
        /// <li> <c>RedrivePolicy</c> - returns the parameters for dead letter queue functionality of the source queue. For more information about
        /// RedrivePolicy and dead letter queues, see <a href="http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html">Using Amazon SQS Dead Letter
        /// Queues</a> in the <i>Amazon SQS Developer Guide</i> .</li>
        /// 
        /// </ul>
        /// </para> <para><b>NOTE:</b>Going forward, new attributes might be added. If you are writing code that calls this action, we recommend that
        /// you structure your code so that it can handle new attributes gracefully.</para> <para><b>NOTE:</b>Some API actions take lists of parameters.
        /// These lists are specified using the param.n notation. Values of n are integers starting from 1. For example, a parameter list with two
        /// elements looks like this: </para> <para> <c>&amp;amp;Attribute.1=this</c> </para> <para> <c>&amp;amp;Attribute.2=that</c> </para>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueAttributes service method on
        /// AmazonSQS.</param>
        /// 
        /// <returns>The response from the GetQueueAttributes service method, as returned by AmazonSQS.</returns>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.InvalidAttributeNameException" />
		public GetQueueAttributesResponse GetQueueAttributes(GetQueueAttributesRequest request)
        {
            var task = GetQueueAttributesAsync(request);
            try
            {
                return task.Result;
            }
            catch(AggregateException e)
            {
                ExceptionDispatchInfo.Capture(e.InnerException).Throw();
                return null;
            }
        }
        /// <summary>
        /// Initiates the asynchronous execution of the GetQueueAttributes operation.
        /// <seealso cref="Amazon.SQS.IAmazonSQS.GetQueueAttributes"/>
        /// </summary>
        /// 
        /// <param name="request">Container for the necessary parameters to execute the GetQueueAttributes 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<GetQueueAttributesResponse> GetQueueAttributesAsync(GetQueueAttributesRequest request, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueAttributesRequestMarshaller();
            var unmarshaller = GetQueueAttributesResponseUnmarshaller.GetInstance();
            var response = await Invoke<IRequest, GetQueueAttributesRequest, GetQueueAttributesResponse>(request, marshaller, unmarshaller, signer, cancellationToken)
                .ConfigureAwait(continueOnCapturedContext: false);
            return response;
        }
        public void Test_GetQueueAttributes_And_Check_For_Valid_Value()
        {
            bool hasCallbackArrived = false;
            string actualValue = "-1";
            string expectedValue = "3";

            SQSResponseEventHandler<object, ResponseEventArgs> handler = null;

            handler = delegate(object sender, ResponseEventArgs args)
            {
                ISQSResponse result = args.Response;
                //Unhook from event.
                _client.OnSQSResponse -= handler;
                GetQueueAttributesResponse response = result as GetQueueAttributesResponse;
                if (null != response)
                {
                    GetQueueAttributesResult attributeResult = response.GetQueueAttributesResult;
                    if (null != attributeResult)
                    {
                        if (response.GetQueueAttributesResult.Attribute.Count > 0)
                            actualValue = response.GetQueueAttributesResult.Attribute[0].Value;
                    }
                }

                hasCallbackArrived = true;
            };

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

            //Create request object.
            GetQueueAttributesRequest request = new GetQueueAttributesRequest();
            request.QueueUrl = string.Format("{0}/{1}", QueueURL, _queue_UnitTesting);
            request.AttributeName.Add("VisibilityTimeout");
            _client.GetQueueAttributes(request);

            EnqueueConditional(() => hasCallbackArrived);
            EnqueueCallback(() => Assert.IsTrue(expectedValue == actualValue));
            EnqueueTestComplete();
        }
 /// <summary>
 /// <para>Gets attributes for the specified queue. The following attributes are supported:
 /// <ul>
 /// <li> <c>All</c> - returns all values.</li>
 /// <li> <c>ApproximateNumberOfMessages</c> - returns the approximate number of visible messages in a queue. For more information, see
 /// Resources Required to Process Messages in the Amazon SQS Developer Guide.</li>
 /// <li> <c>ApproximateNumberOfMessagesNotVisible</c> - returns the approximate number of messages that are not timed-out and not deleted. For
 /// more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.</li>
 /// <li> <c>VisibilityTimeout</c> - returns the visibility timeout for the queue. For more information about visibility timeout, see Visibility
 /// Timeout in the Amazon SQS Developer Guide.</li>
 /// <li> <c>CreatedTimestamp</c> - returns the time when the queue was created (epoch time in seconds).</li>
 /// <li> <c>LastModifiedTimestamp</c> - returns the time when the queue was last changed (epoch time in seconds).</li>
 /// <li> <c>Policy</c> - returns the queue's policy.</li>
 /// <li> <c>MaximumMessageSize</c> - returns the limit of how many bytes a message can contain before Amazon SQS rejects it.</li>
 /// <li> <c>MessageRetentionPeriod</c> - returns the number of seconds Amazon SQS retains a message.</li>
 /// <li> <c>QueueArn</c> - returns the queue's Amazon resource name (ARN).</li>
 /// <li> <c>ApproximateNumberOfMessagesDelayed</c> - returns the approximate number of messages that are pending to be added to the queue.</li>
 /// <li> <c>DelaySeconds</c> - returns the default delay on the queue in seconds.</li>
 /// <li> <c>ReceiveMessageWaitTimeSeconds</c> - returns the time for which a ReceiveMessage call will wait for a message to arrive.</li>
 /// 
 /// </ul>
 /// </para>
 /// </summary>
 /// 
 /// <param name="getQueueAttributesRequest">Container for the necessary parameters to execute the GetQueueAttributes service method on
 ///          AmazonSQS.</param>
 /// 
 /// <returns>The response from the GetQueueAttributes service method, as returned by AmazonSQS.</returns>
 /// 
 /// <exception cref="InvalidAttributeNameException"/>
 public GetQueueAttributesResponse GetQueueAttributes(GetQueueAttributesRequest getQueueAttributesRequest)
 {
     IAsyncResult asyncResult = invokeGetQueueAttributes(getQueueAttributesRequest, null, null, true);
     return EndGetQueueAttributes(asyncResult);
 }
 /// <summary>
 /// Initiates the asynchronous execution of the GetQueueAttributes operation.
 /// <seealso cref="Amazon.SQS.IAmazonSQS.GetQueueAttributes"/>
 /// </summary>
 /// 
 /// <param name="getQueueAttributesRequest">Container for the necessary parameters to execute the GetQueueAttributes 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
 ///         EndGetQueueAttributes operation.</returns>
 public IAsyncResult BeginGetQueueAttributes(GetQueueAttributesRequest getQueueAttributesRequest, AsyncCallback callback, object state)
 {
     return invokeGetQueueAttributes(getQueueAttributesRequest, callback, state, false);
 }
Beispiel #30
0
        public void PopulateQueueAttributes(QueueDescription queue)
        {
            var req = new GetQueueAttributesRequest() {
                QueueUrl = queue.Url
            };

            req.AttributeNames.Add("ApproximateNumberOfMessages");
            req.AttributeNames.Add("MessageRetentionPeriod");

            var response = client.GetQueueAttributes(req);
            if (response.Attributes != null && response.Attributes.Any()) {
                foreach (KeyValuePair<string, string> att in response.Attributes) {
                    switch (att.Key) {
                        case "MessageRetentionPeriod":
                            queue.MessageRetentionPeriod = TimeSpan.FromSeconds(Double.Parse(att.Value));
                            break;
                        case "ApproximateNumberOfMessages":
                            queue.ApproximateNumberOfMessages = Int32.Parse(att.Value);
                            break;
                    }
                }
            }
        }
Beispiel #31
0
        /// <summary>
        /// Returns the approximate number of queued messages
        /// </summary>
        public int ApproximateNumberOfMessages()
        {
            ClearErrorInfo();

            int result = 0;
            try
            {
                GetQueueAttributesRequest attrreq = new GetQueueAttributesRequest();
                attrreq.QueueUrl = queueurl.QueueUrl;
                attrreq.AttributeNames.Add("ApproximateNumberOfMessages");
                GetQueueAttributesResponse attrresp = queue.GetQueueAttributes(attrreq);
                if (attrresp != null)
                    result = attrresp.ApproximateNumberOfMessages;
            }
            catch (Exception ex)
            {
                ErrorCode = e_Exception;
                ErrorMessage = ex.Message;
            }

            return result;
        }
        /// <summary>
        /// <para>Gets attributes for the specified queue. The following attributes are supported:
        /// <ul>
        /// <li> <c>All</c> - returns all values.</li>
        /// <li> <c>ApproximateNumberOfMessages</c> - returns the approximate number of visible messages in a queue. For more information, see
        /// Resources Required to Process Messages in the Amazon SQS Developer Guide.</li>
        /// <li> <c>ApproximateNumberOfMessagesNotVisible</c> - returns the approximate number of messages that are not timed-out and not deleted. For
        /// more information, see Resources Required to Process Messages in the Amazon SQS Developer Guide.</li>
        /// <li> <c>VisibilityTimeout</c> - returns the visibility timeout for the queue. For more information about visibility timeout, see Visibility
        /// Timeout in the Amazon SQS Developer Guide.</li>
        /// <li> <c>CreatedTimestamp</c> - returns the time when the queue was created (epoch time in seconds).</li>
        /// <li> <c>LastModifiedTimestamp</c> - returns the time when the queue was last changed (epoch time in seconds).</li>
        /// <li> <c>Policy</c> - returns the queue's policy.</li>
        /// <li> <c>MaximumMessageSize</c> - returns the limit of how many bytes a message can contain before Amazon SQS rejects it.</li>
        /// <li> <c>MessageRetentionPeriod</c> - returns the number of seconds Amazon SQS retains a message.</li>
        /// <li> <c>QueueArn</c> - returns the queue's Amazon resource name (ARN).</li>
        /// <li> <c>ApproximateNumberOfMessagesDelayed</c> - returns the approximate number of messages that are pending to be added to the queue.</li>
        /// <li> <c>DelaySeconds</c> - returns the default delay on the queue in seconds.</li>
        /// <li> <c>ReceiveMessageWaitTimeSeconds</c> - returns the time for which a ReceiveMessage call will wait for a message to arrive.</li>
        /// 
        /// </ul>
        /// </para>
        /// </summary>
        /// 
        /// <param name="getQueueAttributesRequest">Container for the necessary parameters to execute the GetQueueAttributes service method on
        /// AmazonSQS.</param>
        /// 
        /// <returns>The response from the GetQueueAttributes service method, as returned by AmazonSQS.</returns>
        /// 
        /// <exception cref="T:Amazon.SQS.Model.InvalidAttributeNameException" />
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
		public Task<GetQueueAttributesResponse> GetQueueAttributesAsync(GetQueueAttributesRequest getQueueAttributesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller = new GetQueueAttributesRequestMarshaller();
            var unmarshaller = GetQueueAttributesResponseUnmarshaller.GetInstance();
            return Invoke<IRequest, GetQueueAttributesRequest, GetQueueAttributesResponse>(getQueueAttributesRequest, marshaller, unmarshaller, signer, cancellationToken);
        }
 private Amazon.SQS.Model.GetQueueAttributesResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.GetQueueAttributesRequest request)
 {
     Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "GetQueueAttributes");
     try
     {
         #if DESKTOP
         return(client.GetQueueAttributes(request));
         #elif CORECLR
         return(client.GetQueueAttributesAsync(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;
     }
 }