Amazon.SQS.AmazonSQSClient.GetQueueUrlAsync C# (CSharp) Method

GetQueueUrlAsync() public method

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.

/// The queue referred to doesn't exist. ///
public GetQueueUrlAsync ( string queueName, System cancellationToken = default(CancellationToken) ) : Task
queueName string The name of the queue whose URL must be fetched. Maximum 80 characters. Valid values: alphanumeric characters, hyphens (-), and underscores (_). Queue names are case-sensitive.
cancellationToken System /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. ///
return Task
        public Task<GetQueueUrlResponse> GetQueueUrlAsync(string queueName, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var request = new GetQueueUrlRequest();
            request.QueueName = queueName;
            return GetQueueUrlAsync(request, cancellationToken);
        }

Same methods

AmazonSQSClient::GetQueueUrlAsync ( GetQueueUrlRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::GetQueueUrlAsync ( GetQueueUrlRequest request, GetQueueUrlResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
AmazonSQSClient::GetQueueUrlAsync ( string queueName, GetQueueUrlResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void

Usage Example

Example #1
0
        public async Task SendAsync(string message, CancellationToken token)
        {
            // Console.WriteLine("Sending messages:");

            using (var client = new Amazon.SQS.AmazonSQSClient(accessKey, secretKey, region))
            {
                var queueUrlResult = await client.GetQueueUrlAsync(queueName, token);

                var queueUrl = queueUrlResult.QueueUrl;

                var req = new SendMessageRequest(queueUrl, message);
                if (isFIFO)
                {
                    // required
                    req.MessageGroupId         = "group";
                    req.MessageDeduplicationId = message;
                }
                req.MessageAttributes.Add("CorrelationID", new MessageAttributeValue()
                {
                    DataType    = "string",
                    StringValue = Guid.NewGuid().ToString()
                });
                //req.DelaySeconds = 10;

                var r = await client.SendMessageAsync(req);

                Console.WriteLine("[" + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + "] [P] " + message + " | " + r.MessageId);
            }
        }
All Usage Examples Of Amazon.SQS.AmazonSQSClient::GetQueueUrlAsync
AmazonSQSClient