User guide
Create an Amazon SQS Queue
You can use the AWS SDK for .NET to programmatically create an Amazon SQS queue. Creating an
Amazon SQS Queue is an administrative task.You can create a queue by using the AWS Management
Console instead of creating a queue programmatically.
To create an Amazon SQS queue
1. Create and initialize a CreateQueueRequest instance. Provide the name of your queue and specify
a visibility timeout for your queue messages, as follows:
CreateQueueRequest createQueueRequest =
new CreateQueueRequest();
createQueueRequest.QueueName = "MySQSQueue";
createQueueRequest.DefaultVisibilityTimeout = 10;
Your queue name must only be composed of alphanumeric characters, hyphens, and underscores.
Any message in the queue remains in the queue unless the specified visibility timeout is exceeded.
The default visibility timeout for a queue is 30 seconds. For more information about visibility timeouts,
go to Visibility Timeout. For more information about different queue attributes you can set, go to
SetQueueAttributes.
2. After you create the request, pass it as a parameter to the CreateQueue method.The method returns
a CreateQueueResponse object, as follows:
CreateQueueResponse createQueueResponse =
amazonSQSClient.CreateQueue(createQueueRequest);
For information about how queues work in Amazon SQS, go to How SQS Queues Work.
For information about your queue URL, see Amazon SQS Queue URLs (p. 123).
Amazon SQS Queue URLs
You require the queue URL to send, receive, and delete queue messages. A queue URL is constructed
in the following format:
https://REGION_ENDPOINT/queue.amazonaws.com/YOUR_ACCOUNT_NUMBER/YOUR_QUEUE_NAME
To find your AWS account number, go to Security Credentials .Your account number is located under
Account Number in the upper right of the page.
For information on sending a message to a queue, see Send an Amazon SQS Message (p. 124).
For information about receiving messages from a queue, see Receive a Message from an Amazon SQS
Queue (p. 124).
For information about deleting messages from a queue, see Delete a Message from an Amazon SQS
Queue (p. 125).
Version v2.0.0
123
AWS SDK for .NET Developer Guide
Creating and Using an Amazon SQS Queue