AWS SDK Version 2 for .NET
API Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

.NET Framework 4.5
 
Creates a new queue, or returns the URL of an existing one. When you request CreateQueue, 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.

If you delete a queue, you must wait at least 60 seconds before creating a queue with the same name.

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.

Use GetQueueUrl to get a queue's URL. GetQueueUrl requires only the QueueName parameter.

If you provide the name of an existing queue, along with the exact names and values of all the queue's attributes, CreateQueue returns the queue URL for the existing queue. If the queue name, attribute names, or attribute values do not match an existing queue, CreateQueue returns an error.

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:

&Attribute.1=this

&Attribute.2=that

Namespace: Amazon.SQS
Assembly: AWSSDK.dll
Version: (assembly version)

Syntax

C#
public abstract CreateQueueResponse CreateQueue(
         CreateQueueRequest request
)

Parameters

request
Type: Amazon.SQS.Model.CreateQueueRequest

Container for the necessary parameters to execute the CreateQueue service method.

Return Value
Type: Amazon.SQS.Model.CreateQueueResponse
The response from the CreateQueue service method, as returned by SQS.

Exceptions

ExceptionCondition
QueueDeletedRecentlyException You must wait 60 seconds after deleting a queue before you can create another with the same name.
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.

Examples

This example shows how to create a queue.

Create queue example

var client = new AmazonSQSClient();

var attrs = new Dictionary<string, string>();

// Maximum message size of 256 KiB (1,024 bytes * 256 KiB = 262,144 bytes).
int maxMessage = 256 * 1024;

attrs.Add(QueueAttributeName.DelaySeconds,
  TimeSpan.FromSeconds(5).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.MaximumMessageSize, maxMessage.ToString());
attrs.Add(QueueAttributeName.MessageRetentionPeriod,
  TimeSpan.FromDays(4).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.ReceiveMessageWaitTimeSeconds,
  TimeSpan.FromSeconds(5).TotalSeconds.ToString());
attrs.Add(QueueAttributeName.VisibilityTimeout,
  TimeSpan.FromHours(12).TotalSeconds.ToString());

var request = new CreateQueueRequest
{
  Attributes = attrs,
  QueueName = "MyTestQueue"
};

var response = client.CreateQueue(request);

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

Version Information

.NET Framework:
Supported in: 4.5, 4.0, 3.5