Creating an Amazon SQS Queue - AWS SDK for .NET (version 3)

This documentation is for version 3.0 of the AWS SDK for .NET, which is mostly centered around .NET Framework and ASP.NET 4.x, Windows, and Visual Studio.

The latest version of the documentation at https://docs.aws.amazon.com/sdk-for-net/latest/developer-guide/ is mostly centered around .NET Core and ASP.NET Core. In addition to Windows and Visual Studio, it gives equal consideration to cross-platform development.

Creating an Amazon SQS Queue

Creating an Amazon SQS queue is an administrative task that you can do by using the SQS Management Console. However, you can also use the AWS SDK for .NET to programmatically create an Amazon SQS queue.

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.

    var createQueueRequest = new CreateQueueRequest(); createQueueRequest.QueueName = "MySQSQueue"; var attrs = new Dictionary<string, string>(); attrs.Add(QueueAttributeName.VisibilityTimeout, "10"); createQueueRequest.Attributes = attrs;

    Your queue name must be composed of only 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, see Visibility Timeout. For more information about different queue attributes you can set, see SetQueueAttributes.

  2. After you create the request, pass it as a parameter to the CreateQueue method. The method returns a CreateQueueResponse object, as follows.

    var createQueueResponse = sqsClient.CreateQueue(createQueueRequest);

For information about how queues work in Amazon SQS, see How SQS Queues Work.

For information about your queue URL, see Constructing Amazon SQS Queue URLs.