Try it now and let us know what you think. Switch to the new look >>
You can return to the original look by selecting English in the language selector above.
Tutorial: Creating an Amazon SQS Queue
The first and most common Amazon SQS task is creating queues. In this tutorial you'll learn how to create and configure a queue.
AWS Management Console
-
Sign in to the Amazon SQS console.
-
Choose Create New Queue.
-
On the Create New Queue page, ensure that you're in the correct region and then type the Queue Name.
Note
The name of a FIFO queue must end with the
.fifosuffix. -
Standard is selected by default. Choose FIFO.
-
Create your queue.
-
To create your queue with the default parameters, choose Quick-Create Queue.
-
To configure your queue's parameters, choose Configure Queue. When you finish configuring the parameters, choose Create Queue. For more information about creating a queue with SSE, see Creating an Amazon SQS Queue with SSE.
The following example shows the Content-Based Deduplication parameter specific to FIFO queues.
Your new queue is created and selected in the queue list.
Note
When you create a queue, it can take a short time for the queue to propagate throughout Amazon SQS.
The Queue Type column helps you distinguish standard queues from FIFO queues at a glance. For a FIFO queue, the Content-Based Deduplication column displays whether you have enabled exactly-once processing.
Your queue's Name, URL, and ARN are displayed on the Details tab.
-
AWS SDK for Java
Before you begin working with the example code, specify your AWS credentials. For more information, see Set up AWS Credentials and Region for Development in the AWS SDK for Java Developer Guide.
To create a standard queue
-
Copy the example program.
The following section of the code creates the
MyQueuequeue:// Create a queue System.out.println("Creating a new SQS queue called MyQueue.\n"); final CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyQueue"); final String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl(); -
Compile and run the example.
The queue is created.
To create a FIFO queue
-
Copy the example program.
The following section of the code creates the
MyFifoQueue.fifoqueue:// Create a FIFO queue System.out.println("Creating a new Amazon SQS FIFO queue called " + "MyFifoQueue.fifo.\n"); final Map<String, String> attributes = new HashMap<String, String>(); // A FIFO queue must have the FifoQueue attribute set to True attributes.put("FifoQueue", "true"); // If the user doesn't provide a MessageDeduplicationId, generate a MessageDeduplicationId based on the content. attributes.put("ContentBasedDeduplication", "true"); // The FIFO queue name must end with the .fifo suffix final CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyFifoQueue.fifo") .withAttributes(attributes); final String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl(); -
Compile and run the example.
The queue is created.
AWS CloudFormation
You can use the AWS CloudFormation console and a JSON (or YAML) template to create
an Amazon SQS queue.
For more information, see Working with AWS CloudFormation Templates and
the AWS::SQS::Queue Resource in the
AWS CloudFormation User Guide.
-
Copy the following JSON code to a file named
MyQueue.json. To create a standard queue, omit theFifoQueueandContentBasedDeduplicationproperties. For more information on content-based deduplication, see Exactly-Once Processing.Note
The name of a FIFO queue must end with the
.fifosuffix.{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "MyQueue": { "Properties": { "QueueName": "MyQueue.fifo", "FifoQueue": true, "ContentBasedDeduplication": true }, "Type": "AWS::SQS::Queue" } }, "Outputs": { "QueueName": { "Description": "The name of the queue", "Value": { "Fn::GetAtt": [ "MyQueue", "QueueName" ] } }, "QueueURL": { "Description": "The URL of the queue", "Value": { "Ref": "MyQueue" } }, "QueueARN": { "Description": "The ARN of the queue", "Value": { "Fn::GetAtt": [ "MyQueue", "Arn" ] } } } } -
Sign in to the AWS CloudFormation console, and then choose Create Stack.
-
On the Select Template page, choose Upload a template to Amazon S3, choose your
MyQueue.jsonfile, and then choose Next. -
On the Specify Details page, type
MyQueuefor Stack Name, and then choose Next. -
On the Options page, choose Next.
-
On the Review page, choose Create.
AWS CloudFormation begins to create the
MyQueuestack and displays the CREATE_IN_PROGRESS status. When the process is complete, AWS CloudFormation displays the CREATE_COMPLETE status.
-
(Optional) To display the name, URL, and ARN of the queue, choose the name of the stack and then on the next page expand the Outputs section.


