public void Can_create_and_get_attributes_and_url_correctly() { var createRequest = new CreateQueueRequest { QueueName = Guid.NewGuid().ToString("N"), Attributes = new Dictionary<string, string> { { QueueAttributeName.VisibilityTimeout, "23" }, { QueueAttributeName.ReceiveMessageWaitTimeSeconds, "13" }, } }; var createResponse = client.CreateQueue(createRequest); Assert.That(createResponse.QueueUrl, Is.Not.Null.Or.Empty); var attrResponse = client.GetQueueAttributes(createResponse.QueueUrl, new List<string> { "All" }); Assert.AreEqual(attrResponse.Attributes[QueueAttributeName.VisibilityTimeout], createRequest.Attributes[QueueAttributeName.VisibilityTimeout]); Assert.AreEqual(attrResponse.Attributes[QueueAttributeName.ReceiveMessageWaitTimeSeconds], createRequest.Attributes[QueueAttributeName.ReceiveMessageWaitTimeSeconds]); var qUrlResponse = client.GetQueueUrl(createRequest.QueueName); Assert.AreEqual(qUrlResponse.QueueUrl, createResponse.QueueUrl); }
public void create_queue() { var request = new CreateQueueRequest().WithQueueName("Test_for_blog"); var response = _client.CreateQueue(request); Console.WriteLine(response.CreateQueueResult.QueueUrl); }
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member public async Task <CreateQueueResponse> CreateQueueAsync(string queueName, Dictionary <string, string> attributes = null, CancellationToken cancellationToken = default) { this.Logger.LogDebug($"[{nameof(this.CreateQueueAsync)}]"); this.Logger.LogTrace(JsonConvert.SerializeObject(new { queueName, attributes })); if (string.IsNullOrWhiteSpace(queueName)) { throw new ArgumentNullException(nameof(queueName)); } var request = new Amazon.SQS.Model.CreateQueueRequest { Attributes = attributes, QueueName = queueName, }; this.Logger.LogTrace(JsonConvert.SerializeObject(value: request)); var response = await this.Repository.CreateQueueAsync(request : request, cancellationToken : cancellationToken == default?this.CancellationToken.Token : cancellationToken); this.Logger.LogTrace(JsonConvert.SerializeObject(value: response)); return(response); }
public bool CreateQueue(string name) { var request = new CreateQueueRequest() .WithQueueName(name); _sqsClient.CreateQueue(request); return true; }
/// <summary> /// Creates a SQS queue /// </summary> /// <param name="queueName"></param> /// <returns></returns> public string CreateQueue(string queueName) { var request = new CreateQueueRequest { QueueName = queueName }; CreateQueueResponse response = Client.CreateQueue(request); return response.CreateQueueResult.QueueUrl; }
public virtual void CreateQueue(string queueName) { var client = this.GetClient(); var request = new CreateQueueRequest { QueueName = queueName, }; var response = client.CreateQueue(request); }
private static void EnsureQueue(IServiceHandler handler) { if (!_registeredHandlerUrls.ContainsKey(handler.QueueName)) { var createQueueRequest = new CreateQueueRequest(); createQueueRequest.QueueName = handler.QueueName; var createQueueResponse = SqsClient.CreateQueue(createQueueRequest); var queueUrl = createQueueResponse.CreateQueueResult.QueueUrl; _registeredHandlerUrls[handler.QueueName] = queueUrl; } handler.QueueUrl = _registeredHandlerUrls[handler.QueueName]; }
protected override void EndProcessing() { AmazonSQS client = base.GetClient(); CreateQueueRequest request = new CreateQueueRequest(); request.QueueName = this.QueueName; if (null != this.DefaultVisibilityTimeout) request.DefaultVisibilityTimeout = this.DefaultVisibilityTimeout.Value; CreateQueueResponse response = client.CreateQueue(request); WriteObject(response.CreateQueueResult); }
public virtual string CreateQueue(AmazonSQSClient sqsClient, string queueName) { string queueUrl; // Create the request var createQueueRequest = new CreateQueueRequest {QueueName = queueName}; // Submit the request CreateQueueResponse createQueueResponse = sqsClient.CreateQueue(createQueueRequest); // Return the URL for the newly created queue queueUrl = createQueueResponse.QueueUrl; return queueUrl; }
static void Main(string[] args) { Console.Title = "CloudServiceBus: Client"; AmazonSQS sqs = AwsFacade.GetSqsClient(); var requestQueueUrl = ConfigurationManager.AppSettings["QueueUrl"]; //create a queue for responses: var queueName = Guid.NewGuid().ToString(); var createQueueRequest = new CreateQueueRequest(); createQueueRequest.QueueName = queueName; var createQueueResponse = sqs.CreateQueue(createQueueRequest); var responseQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl; var listener = new MessageListener(); ThreadPool.QueueUserWorkItem(new WaitCallback(listener.StartListening), responseQueueUrl); Console.WriteLine("*"); Console.WriteLine("Sending messages on URL: {0}", requestQueueUrl); Console.WriteLine("Receiving responses on URL: {0}", responseQueueUrl); Console.WriteLine("*"); var messageBody = Console.ReadLine(); while (messageBody != "x") { var parts = messageBody.Split(' '); if (parts[0] == "get") { var duration = int.Parse(parts[1]); var serviceRequest = new GetChangedEmployeesRequest(); serviceRequest.LastChangeDate = DateTime.Now.AddDays(duration).Date; serviceRequest.ResponseQueueUrl = responseQueueUrl; var request = new SendMessageRequest(); request.QueueUrl = requestQueueUrl; request.RequestToBody(serviceRequest); SendMessage(request, sqs, serviceRequest); } if (parts[0] == "flush") { var serviceRequest = new FlushDataStoreRequest(); serviceRequest.StoreIdentifier = "Sixeyed-CloudServiceBus-ResponseData"; var request = new SendMessageRequest(); request.QueueUrl = requestQueueUrl; request.RequestToBody(serviceRequest); SendMessage(request, sqs, serviceRequest); } messageBody = Console.ReadLine(); } }
public static string CreateQueue(string name) { using (var client = new AmazonSQSClient(Settings.AccessKey, Settings.Secret)) { var request = new CreateQueueRequest { QueueName = name }; var response = client.CreateQueue(request); return response.QueueUrl; } }
private static string CreateQueue(string queueName, string deadLetterQueueArn) { var request = new CreateQueueRequest { QueueName = queueName }; request.Attributes.Add(QueueAttributeName.MaximumMessageSize, "128"); if (!string.IsNullOrEmpty(deadLetterQueueArn)) { request.Attributes.Add(QueueAttributeName.RedrivePolicy, "{\"maxReceiveCount\":\"3\", \"deadLetterTargetArn\":\"" + deadLetterQueueArn + "\"}"); } var response = _client.CreateQueue(request); if (response.HttpStatusCode != HttpStatusCode.OK) throw new Exception("Http error " + (int)response.HttpStatusCode); return response.QueueUrl; }
/// <summary> /// CreateSubmitQueue: IAM Account on consumer must have permission/policy to Receive and Delete /// messages from this queue. /// /// </summary> /// <param name="queueName"></param> /// <returns></returns> private string CreateSubmitQueue(string queueName) { Debug.WriteLine("Queuename: " + queueName); var msg1 = new Amazon.SQS.Model.CreateQueueRequest() .WithQueueName(queueName) .WithDefaultVisibilityTimeout(60) .WithDelaySeconds(20); Amazon.SQS.Model.CreateQueueResponse rsp = queue.CreateQueue(msg1); if (rsp.CreateQueueResult.IsSetQueueUrl()) { return(rsp.CreateQueueResult.QueueUrl); } return(null); }
public Uri CreateOrRetrieveQueue(string name) { Validate.That(name).IsNotNullOrEmpty(); var longPollAttribute = new Attribute().WithName(receiveMessageWaitTimeSecondsAttributeName) .WithValue(Convert.ToString(receiveMessageWaitTimeSeconds)); var messageRetainAttribute = new Attribute().WithName(messageRetentionPeriodAttributeName) .WithValue(Convert.ToString(messageRetentionPeriodSeconds)); var sqsRequest = new CreateQueueRequest().WithQueueName(name).WithAttribute(longPollAttribute, messageRetainAttribute); using (var sqs = amazonSqsFactory()) { var createQueueResponse = sqs.CreateQueue(sqsRequest); return new Uri(createQueueResponse.CreateQueueResult.QueueUrl); } }
private void button1_Click(object sender, EventArgs e) { CreateQueueRequest sqsRequest = new CreateQueueRequest(); sqsRequest.QueueName = "MYFirstQueue"; CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest); myQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl; //Confirming the queue exists ListQueuesRequest listQueuesRequest = new ListQueuesRequest(); ListQueuesResponse listQueuesResponse = sqs.ListQueues(listQueuesRequest); SendMessageRequest sendMessageRequest = new SendMessageRequest(); sendMessageRequest.QueueUrl = myQueueUrl; sendMessageRequest.MessageBody = txtPushMsg.Text; sqs.SendMessage(sendMessageRequest); }
public Uri CreateOrRetrieveQueue(string name) { name.Requires("name").IsNotNullOrWhiteSpace(); var attributes = new Dictionary<string, string> { {QueueAttributeName.ReceiveMessageWaitTimeSeconds, Convert.ToString(ReceiveMessageWaitTimeSeconds)}, {QueueAttributeName.MessageRetentionPeriod, Convert.ToString(MessageRetentionPeriodSeconds)} }; var sqsRequest = new CreateQueueRequest(name) {Attributes = attributes}; using (var sqs = amazonSqsFactory()) { var createQueueResponse = sqs.CreateQueue(sqsRequest); return new Uri(createQueueResponse.QueueUrl); } }
protected override bool Execute(AmazonSQS client) { Logger.LogMessage(MessageImportance.Normal, "Creating SQS Queue {0}", QueueName); var request = new CreateQueueRequest { QueueName = QueueName }; CreateQueueResponse response = client.CreateQueue(request); if (response.IsSetCreateQueueResult()) { QueueUrl = response.CreateQueueResult.QueueUrl; Logger.LogMessage(MessageImportance.Normal, "Creates SQS Queue {0} at {1}", QueueName, QueueUrl); return true; } Logger.LogMessage(MessageImportance.Normal, "Failed to create SQS Queue {0}", QueueName); return false; }
/// <summary> /// /// The CreateQueue action creates a new queue. You must provide a queue name that is unique within the scope of the queues you own. The queue is assigned a queue URL; you must use this URL when performing actions on the queue. When you create a queue, if a queue with the same name already exists, CreateQueue returns the queue URL with an error indicating that the queue already exists. /// /// </summary> /// <param name="service">Instance of AmazonSQS service</param> /// <param name="request">CreateQueueRequest request</param> public static void InvokeCreateQueue(AmazonSQS service, CreateQueueRequest request) { try { CreateQueueResponse response = service.CreateQueue(request); Console.WriteLine ("Service Response"); Console.WriteLine ("============================================================================="); Console.WriteLine (); Console.WriteLine(" CreateQueueResponse"); if (response.IsSetCreateQueueResult()) { Console.WriteLine(" CreateQueueResult"); CreateQueueResult createQueueResult = response.CreateQueueResult; if (createQueueResult.IsSetQueueUrl()) { Console.WriteLine(" QueueUrl"); Console.WriteLine(" {0}", createQueueResult.QueueUrl); } } if (response.IsSetResponseMetadata()) { Console.WriteLine(" ResponseMetadata"); ResponseMetadata responseMetadata = response.ResponseMetadata; if (responseMetadata.IsSetRequestId()) { Console.WriteLine(" RequestId"); Console.WriteLine(" {0}", responseMetadata.RequestId); } } } catch (AmazonSQSException ex) { Console.WriteLine("Caught Exception: " + ex.Message); Console.WriteLine("Response Status Code: " + ex.StatusCode); Console.WriteLine("Error Code: " + ex.ErrorCode); Console.WriteLine("Error Type: " + ex.ErrorType); Console.WriteLine("Request ID: " + ex.RequestId); Console.WriteLine("XML: " + ex.XML); } }
public object Execute(ExecutorContext context) { var cmdletContext = context as CmdletContext; // create request var request = new Amazon.SQS.Model.CreateQueueRequest(); if (cmdletContext.Attribute != null) { request.Attributes = cmdletContext.Attribute; } if (cmdletContext.QueueName != null) { request.QueueName = cmdletContext.QueueName; } if (cmdletContext.Tag != null) { request.Tags = cmdletContext.Tag; } 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 static bool Create_Q(String Q_name, out String Q_url, out String Q_arn) { Q_url = String.Empty; Q_arn = String.Empty; CreateQueueRequest cq_request = new CreateQueueRequest(); cq_request.QueueName = Q_name; CreateQueueResponse cq_response = sqs_client.CreateQueue(cq_request); Q_url = cq_response.CreateQueueResult.QueueUrl; if (Q_url.EndsWith(Q_name)) { if (!Get_Q_arn(Q_url, out Q_arn)) { Console.WriteLine("Get_Q_arn(Q_name=" + Q_name + ", out Q_arn) failed!!!"); return false; } return true; } return false; }
public CraneChatRequestSender() { // initialize Amazon SQSClient AmazonSQSConfig sqsConfig = new AmazonSQSConfig(); sqsConfig.ServiceURL = ConfigurationManager.AppSettings["SQSServiceURL"].ToString(); m_sqsClient = AWSClientFactory.CreateAmazonSQSClient(sqsConfig); // create 'Request' queue and save its URL if (null != m_sqsClient) { try { CreateQueueRequest createQueueRequest = new CreateQueueRequest().WithQueueName("Request"); CreateQueueResponse createQueueResponse = m_sqsClient.CreateQueue(createQueueRequest); m_requestQueueUrl = createQueueResponse.CreateQueueResult.QueueUrl; } catch (AmazonSQSException /*sqsException*/) { throw; } } }
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> /// CreateQueueTopicPolicy: Create Request Queue that subscribes to Topic, /// add permission/policy so topic can publish to the Queue /// </summary> /// <param name="queueName"></param> /// <returns></returns> private string CreateQueueTopicPolicy(string queueName) { Debug.WriteLine("Queuename: " + queueName); var msg1 = new Amazon.SQS.Model.CreateQueueRequest() .WithQueueName(queueName) .WithDefaultVisibilityTimeout(60) .WithDelaySeconds(20); Amazon.SQS.Model.CreateQueueResponse rsp = queue.CreateQueue(msg1); if (rsp.CreateQueueResult.IsSetQueueUrl()) { var attr = queue.GetQueueAttributes(new Amazon.SQS.Model.GetQueueAttributesRequest() .WithQueueUrl(rsp.CreateQueueResult.QueueUrl) .WithAttributeName(new string[] { "QueueArn" })); if (attr.IsSetGetQueueAttributesResult() && attr.GetQueueAttributesResult.IsSetAttribute()) { var policy = new Policy("QueuePolicy" + queueName); policy.WithStatements(new Statement(Statement.StatementEffect.Allow) .WithPrincipals(new Principal("*")) .WithActionIdentifiers(Amazon.Auth.AccessControlPolicy.ActionIdentifiers.SQSActionIdentifiers.SendMessage) .WithResources(new Resource(attr.GetQueueAttributesResult.QueueARN)) .WithConditions(Amazon.Auth.AccessControlPolicy.ConditionFactory.NewSourceArnCondition(topicArn))); var setAttrsRequest = new Amazon.SQS.Model.SetQueueAttributesRequest() .WithQueueUrl(rsp.CreateQueueResult.QueueUrl); setAttrsRequest.Attribute.Add(new Amazon.SQS.Model.Attribute() .WithName("Policy") .WithValue(policy.ToJson())); var setAttrsResponse = queue.SetQueueAttributes(setAttrsRequest); } return(rsp.CreateQueueResult.QueueUrl); } return(null); }
/// <summary> /// <para>The <c>CreateQueue</c> action creates a new queue, or returns the URL of an existing one. When you request <c>CreateQueue</c> , you /// provide a name for the queue. To successfully create a new queue, you must provide a name that is unique within the scope of your own /// queues.</para> <para>You may pass one or more attributes in the request. If you do not provide a value for any attribute, the queue will /// have the default value for that attribute. Permitted attributes are the same that can be set using SetQueueAttributes.</para> <para>If you /// provide the name of an existing queue, a new queue isn't created. If the values of attributes provided with the request match up with those /// on the existing queue, the queue URL is returned. Otherwise, a <c>QueueNameExists</c> error is returned.</para> /// </summary> /// /// <param name="createQueueRequest">Container for the necessary parameters to execute the CreateQueue service method on AmazonSQS.</param> /// /// <returns>The response from the CreateQueue service method, as returned by AmazonSQS.</returns> /// /// <exception cref="T:Amazon.SQS.Model.QueueNameExistsException" /> /// <exception cref="T:Amazon.SQS.Model.QueueDeletedRecentlyException" /> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> public Task<CreateQueueResponse> CreateQueueAsync(CreateQueueRequest createQueueRequest, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateQueueRequestMarshaller(); var unmarshaller = CreateQueueResponseUnmarshaller.GetInstance(); return Invoke<IRequest, CreateQueueRequest, CreateQueueResponse>(createQueueRequest, marshaller, unmarshaller, signer, cancellationToken); }
internal CreateQueueResponse CreateQueue(CreateQueueRequest request) { var task = CreateQueueAsync(request); try { return task.Result; } catch(AggregateException e) { throw e.InnerException; } }
private SqsQueueDefinition CreateQueue(SqsQueueName queueName, int? visibilityTimeoutSeconds = null, int? receiveWaitTimeSeconds = null, bool? disasbleBuffering = null, SqsRedrivePolicy redrivePolicy = null) { SqsQueueDefinition queueDefinition = null; var request = new CreateQueueRequest { QueueName = queueName.AwsQueueName, Attributes = new Dictionary<string, string> { { QueueAttributeName.ReceiveMessageWaitTimeSeconds, TimeSpan.FromSeconds(receiveWaitTimeSeconds ?? DefaultReceiveWaitTime) .TotalSeconds .ToString(CultureInfo.InvariantCulture) }, { QueueAttributeName.VisibilityTimeout, TimeSpan.FromSeconds(visibilityTimeoutSeconds ?? DefaultVisibilityTimeout) .TotalSeconds .ToString(CultureInfo.InvariantCulture) }, { QueueAttributeName.MessageRetentionPeriod, (QueueNames.IsTempQueue(queueName.QueueName) ? SqsQueueDefinition.DefaultTempQueueRetentionSeconds : SqsQueueDefinition.DefaultPermanentQueueRetentionSeconds).ToString(CultureInfo.InvariantCulture) } } }; if (redrivePolicy != null) { var json = AwsClientUtils.ToJson(redrivePolicy); request.Attributes.Add(QueueAttributeName.RedrivePolicy, json); } try { var createResponse = SqsClient.CreateQueue(request); // Note - must go fetch the attributes from the server after creation, as the request attributes do not include // anything assigned by the server (i.e. the ARN, etc.). queueDefinition = GetQueueDefinition(queueName, createResponse.QueueUrl); queueDefinition.DisableBuffering = disasbleBuffering ?? DisableBuffering; queueNameMap[queueDefinition.QueueName] = queueDefinition; } catch (QueueNameExistsException) { // Queue exists with different attributes, instead of creating, alter those attributes to match what was requested queueDefinition = UpdateQueue(queueName, request.ToSetAttributesRequest(null), disasbleBuffering); } return queueDefinition; }
// returns queue url private string CreateUserResponseQueue(string userName) { string queueURL = null; if (!m_ResponseQueueURLCach.TryGetValue(userName, out queueURL)) { // create 'Request' queue and save its URL try { CreateQueueRequest createQueueRequest = new CreateQueueRequest().WithQueueName(CraneChatUtility.MakeUserResponseQueueName(userName)); CreateQueueResponse createQueueResponse = m_sqsClient.CreateQueue(createQueueRequest); queueURL = createQueueResponse.CreateQueueResult.QueueUrl; } catch (AmazonSQSException /*sqsException*/) { throw; } m_ResponseQueueURLCach.Add(userName, queueURL); } return queueURL; }
/// <summary> /// <para>Creates a new queue, or returns the URL of an existing one. When you request <c>CreateQueue</c> , you provide a name for the queue. To /// successfully create a new queue, you must provide a name that is unique within the scope of your own queues.</para> <para><b>NOTE:</b> If /// you delete a queue, you must wait at least 60 seconds before creating a queue with the same name. </para> <para>You may pass one or more /// attributes in the request. If you do not provide a value for any attribute, the queue will have the default value for that attribute. /// Permitted attributes are the same that can be set using SetQueueAttributes.</para> <para><b>NOTE:</b> Use GetQueueUrl to get a queue's URL. /// GetQueueUrl requires only the QueueName parameter. </para> <para>If you provide the name of an existing queue, along with the exact names /// and values of all the queue's attributes, <c>CreateQueue</c> returns the queue URL for the existing queue. If the queue name, attribute /// names, or attribute values do not match an existing queue, <c>CreateQueue</c> returns an error.</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;Attribute.1=this</c> </para> <para> /// <c>&amp;Attribute.2=that</c> </para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateQueue service method on AmazonSQS.</param> /// /// <returns>The response from the CreateQueue service method, as returned by AmazonSQS.</returns> /// /// <exception cref="T:Amazon.SQS.Model.QueueNameExistsException" /> /// <exception cref="T:Amazon.SQS.Model.QueueDeletedRecentlyException" /> public CreateQueueResponse CreateQueue(CreateQueueRequest request) { var task = CreateQueueAsync(request); try { return task.Result; } catch(AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return null; } }
private static void EnsureQueue() { if (!string.IsNullOrEmpty(queueUrl)) return; EnsureSqs(); lock (lockObject) { CreateQueueRequest sqsRequest = new CreateQueueRequest(); sqsRequest.QueueName = ConfigurationManager.AppSettings["awssqsqueue"] ; if (sqsRequest.QueueName == null) { Logger.Info(string.Format("awssqsqueue not configured, configure it first!")); return; } CreateQueueResponse createQueueResponse = sqs.CreateQueue(sqsRequest); queueUrl = createQueueResponse.CreateQueueResult.QueueUrl; } }
/// <summary> /// Initiates the asynchronous execution of the CreateQueue operation. /// <seealso cref="Amazon.SQS.IAmazonSQS.CreateQueue"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateQueue 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<CreateQueueResponse> CreateQueueAsync(CreateQueueRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateQueueRequestMarshaller(); var unmarshaller = CreateQueueResponseUnmarshaller.GetInstance(); var response = await Invoke<IRequest, CreateQueueRequest, CreateQueueResponse>(request, marshaller, unmarshaller, signer, cancellationToken) .ConfigureAwait(continueOnCapturedContext: false); return response; }
/// <summary> /// Initiates the asynchronous execution of the CreateQueue operation. /// <seealso cref="Amazon.SQS.IAmazonSQS"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateQueue 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 EndCreateQueue /// operation.</returns> public IAsyncResult BeginCreateQueue(CreateQueueRequest request, AsyncCallback callback, object state) { var marshaller = new CreateQueueRequestMarshaller(); var unmarshaller = CreateQueueResponseUnmarshaller.Instance; return BeginInvoke<CreateQueueRequest>(request, marshaller, unmarshaller, callback, state); }
/// <summary> /// Creates a new queue, or returns the URL of an existing one. When you request /// <code>CreateQueue</code>, you provide a name for the queue. To successfully create /// a new queue, you must provide a name that is unique within the scope of your /// own queues. /// /// <note> /// <para> /// If you delete a queue, you must wait at least 60 seconds before creating a queue with /// the same name. /// </para> /// </note> /// <para> /// You may pass one or more attributes in the request. If you do not provide a value /// for any attribute, the queue will have the default value for that attribute. /// Permitted attributes are the same that can be set using <a>SetQueueAttributes</a>. /// </para> /// <note> /// <para> /// Use <a>GetQueueUrl</a> to get a queue's URL. <a>GetQueueUrl</a> requires only /// the <code>QueueName</code> parameter. /// </para> /// </note> /// <para> /// If you provide the name of an existing queue, along with the exact names and values /// of all the queue's attributes, <code>CreateQueue</code> returns the queue URL /// for the existing queue. If the queue name, attribute names, or attribute values /// do not match an existing queue, <code>CreateQueue</code> returns an error. /// </para> /// <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>&Attribute.1=this</code> /// </para> /// /// <para> /// <code>&Attribute.2=that</code> /// </para> /// </summary> /// <param name="request">Container for the necessary parameters to execute the CreateQueue service method.</param> /// /// <returns>The response from the CreateQueue service method, as returned by SQS.</returns> /// <exception cref="QueueDeletedRecentlyException"> /// You must wait 60 seconds after deleting a queue before you can create another /// with the same name. /// </exception> /// <exception cref="QueueNameExistsException"> /// A queue already exists with this name. Amazon SQS returns this error only if the request /// includes attributes whose values differ from those of the existing queue. /// </exception> public CreateQueueResponse CreateQueue(CreateQueueRequest request) { var marshaller = new CreateQueueRequestMarshaller(); var unmarshaller = CreateQueueResponseUnmarshaller.Instance; return Invoke<CreateQueueRequest,CreateQueueResponse>(request, marshaller, unmarshaller); }
/// <summary> /// Creates a new queue, or returns the URL of an existing one. When you request /// <code>CreateQueue</code>, you provide a name for the queue. To successfully create /// a new queue, you must provide a name that is unique within the scope of your /// own queues. /// /// <note> /// <para> /// If you delete a queue, you must wait at least 60 seconds before creating a queue with /// the same name. /// </para> /// </note> /// <para> /// You may pass one or more attributes in the request. If you do not provide a value /// for any attribute, the queue will have the default value for that attribute. /// Permitted attributes are the same that can be set using <a>SetQueueAttributes</a>. /// </para> /// <note> /// <para> /// Use <a>GetQueueUrl</a> to get a queue's URL. <a>GetQueueUrl</a> requires only /// the <code>QueueName</code> parameter. /// </para> /// </note> /// <para> /// If you provide the name of an existing queue, along with the exact names and values /// of all the queue's attributes, <code>CreateQueue</code> returns the queue URL /// for the existing queue. If the queue name, attribute names, or attribute values /// do not match an existing queue, <code>CreateQueue</code> returns an error. /// </para> /// <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>&Attribute.1=this</code> /// </para> /// /// <para> /// <code>&Attribute.2=that</code> /// </para> /// </summary> /// <param name="queueName">The name for the queue to be created.</param> /// /// <returns>The response from the CreateQueue service method, as returned by SQS.</returns> /// <exception cref="QueueDeletedRecentlyException"> /// You must wait 60 seconds after deleting a queue before you can create another /// with the same name. /// </exception> /// <exception cref="QueueNameExistsException"> /// A queue already exists with this name. Amazon SQS returns this error only if the request /// includes attributes whose values differ from those of the existing queue. /// </exception> public CreateQueueResponse CreateQueue(string queueName) { var request = new CreateQueueRequest(); request.QueueName = queueName; return CreateQueue(request); }
/// <summary> /// Initiates the asynchronous execution of the CreateQueue operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateQueue 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<CreateQueueResponse> CreateQueueAsync(CreateQueueRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateQueueRequestMarshaller(); var unmarshaller = CreateQueueResponseUnmarshaller.Instance; return InvokeAsync<CreateQueueRequest,CreateQueueResponse>(request, marshaller, unmarshaller, cancellationToken); }
private Amazon.SQS.Model.CreateQueueResponse CallAWSServiceOperation(IAmazonSQS client, Amazon.SQS.Model.CreateQueueRequest request) { Utils.Common.WriteVerboseEndpointMessage(this, client.Config, "Amazon Simple Queue Service (SQS)", "CreateQueue"); try { #if DESKTOP return(client.CreateQueue(request)); #elif CORECLR return(client.CreateQueueAsync(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; } }