Menu
Amazon Simple Queue Service
Developer Guide

Tutorial: Creating an Amazon SQS Queue

The first and most common Amazon SQS task is creating queues. The following example demonstrates how to create and configure a queue.

AWS Management Console

  1. Sign in to the AWS Management Console and open the Amazon SQS console at https://console.aws.amazon.com/sqs/.

  2. Choose Create New Queue.

  3. 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 .fifo suffix. FIFO queues are available in US West (Oregon) and US East (Ohio).

  4. Standard is selected by default. Choose FIFO.

  5. 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.

      The following example shows the Content-Based Deduplication parameter specific to FIFO queues.

    Your new queue is created and selected in the queue list. 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 URL and ARN are displayed on the Details tab.

Java

Before you begin working with the example code, specify your AWS credentials. For more information, see Set Up AWS Credentials for Development in the AWS SDK for Java Developer Guide.

To create a standard queue

  1. Copy the example program.

    The following section of the code creates the MyQueue queue:

    // Create a queue
    System.out.println("Creating a new SQS queue called MyQueue.\n");
    CreateQueueRequest createQueueRequest = new CreateQueueRequest().withQueueName("MyQueue");
    String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
  2. Compile and run the example.

    The queue is created.

To create a FIFO queue

  1. Copy the example program.

    The following section of the code creates the MyFifoQueue.fifo queue:

    // Create a FIFO queue
    System.out.println("Creating a new Amazon SQS FIFO queue called MyFifoQueue.fifo.\n");
    Map<String, String> attributes = new HashMap<String, String>();
    // A FIFO queue must have the FifoQueue attribute set to True
    attributes.put("FifoQueue", "true");
    // Generate a MessageDeduplicationId based on the content, if the user doesn't provide a MessageDeduplicationId
    attributes.put("ContentBasedDeduplication", "true");
    // The FIFO queue name must end with the .fifo suffix
    CreateQueueRequest createQueueRequest = new CreateQueueRequest("MyFifoQueue.fifo").withAttributes(attributes);
    String myQueueUrl = sqs.createQueue(createQueueRequest).getQueueUrl();
  2. Compile and run the example.

    The queue is created.