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

GetQueueUrlAsync() public method

Initiates the asynchronous execution of the GetQueueUrl operation.
public GetQueueUrlAsync ( GetQueueUrlRequest request, GetQueueUrlResponse>.AmazonServiceCallback callback, AsyncOptions options = null ) : void
request Amazon.SQS.Model.GetQueueUrlRequest Container for the necessary parameters to execute the GetQueueUrl operation on AmazonSQSClient.
callback GetQueueUrlResponse>.AmazonServiceCallback An Action delegate that is invoked when the operation completes.
options Amazon.Runtime.AsyncOptions A user-defined state object that is passed to the callback procedure. Retrieve this object from within the callback /// procedure using the AsyncState property.
return void
        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);
        }

Same methods

AmazonSQSClient::GetQueueUrlAsync ( GetQueueUrlRequest request, System cancellationToken = default(CancellationToken) ) : Task
AmazonSQSClient::GetQueueUrlAsync ( string queueName, System cancellationToken = default(CancellationToken) ) : Task
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