Amazon Simple Queue Service
Getting Started Guide (API Version 2011-10-01)
Print this pageEmail this pageGo to the ForumsView the PDFShare this page on TwitterShare this page on FacebookBookmark this page on DeliciousSubmit this page to RedditSubmit this page to DiggDid this page help you?  Yes  No   Tell us about it...

Preparing the Samples

To complete the subsequent sections in this guide, you must make configuration changes to the sample files.

[Tip]Tip

If you don't want to write code, you can use the AWS Management Console or Amazon SQS scratchpad, a simple HTML and JavaScript application.

AWS Management Console

The easiest way to explore Amazon SQS without writing any code is with the AWS Management Console.

To access SQS with the AWS Management Console

  1. Sign in to the AWS Management Console.

  2. Select the Amazon SQS tab.

Scratchpad

An easy way to explore Amazon SQS without writing any code is with the Amazon SQS scratchpad. To use the scratchpad, you must have an AWS account and be signed up for SQS (for more information, see Creating an AWS Account and Signing Up for SQS).

The scratchpad is a simple HTML and JavaScript application based on the 2009-02-01 version of SQS. You can use the scratchpad to understand what Query requests and responses for SQS look like, and to troubleshoot signature issues with Query requests.

To prepare the scratchpad

  1. Go to the scratchpad download.

  2. Download the scratchpad and extract it to a working directory on your computer.

  3. Open the index.html file with a web browser.

    The welcome page is displayed.

    Scratchpad
  4. Enter your Access Key ID and Secret Access Key (for more information, see Getting Your AWS Identifiers).

  5. Follow the tutorial described in the remainder of this guide.

Java

Note that the Java example performs all actions in one call: creating a queue, confirming the queue exists, sending a message, receiving a message, and deleting a message.

To prepare the sample files

  1. Go to the AWS SDK for Java page and download the SDK.

  2. Download the aws-java-sdk-1.0.0.20100226.zip file and unzip it to a directory designated as <sqs home> on your machine.

  3. Open the AWS credentials file: <sqs home>/aws-java-sdk/samples/AmazonSimpleQueueService/AwsCredentials.properties.

  4. Enter your Access Key ID and Secret Access Key:

    # Fill in your AWS Access Key ID and Secret Access Key
     # http://aws.amazon.com/security-credentials
     accessKey = <Your AWS Access Key ID>
     secretKey = <Your Secret Access Key>
  5. Save the file.

C#

Note that the C# example performs all actions in one call: creating a queue, confirming the queue exists, sending a message, receiving a message, and deleting a message.

To prepare the sample files

  1. Go to the AWS SDK for .NET page and download the SDK.

  2. Run the downloaded installation program, AWSToolsAndSDKForNet.msi.

    The installation installs to C:\Program Files\AWS SDK for .NET by default.

  3. Go to C:\Program Files\AWS SDK for .NET\Samples\AmazonSQS_Sample and open one of the following sample solutions:

    • AmazonSQS_Sample.VS2008.sln

    • AmazonSQS_Sample.VS2010.sln

  4. Open the App.config file.

  5. Enter your Access Key ID and Secret Access Key:

    <configuration>
      <appSettings>
        <add key="AWSAccessKey" value="<Your Access Key ID>"/>
        <add key="AWSSecretKey" value="<Your Secret Access Key>"/>
      </appSettings>
    </configuration>
  6. Save the file.

Perl

To prepare the sample files

  1. Go to the location of the Perl sample code that AWS provides and download the sample code package.

  2. Extract the sample code into a directory on your machine.

  3. Prepare each of the individual samples:

    1. Open the amazon-queue-2009-02-01-perl-library/src/Amazon/SQS/Samples/CreateQueueSample.pl sample file.

    2. Make sure the following lines are not commented out and enter your Access Key ID and Secret Access Key.

      my $AWS_ACCESS_KEY_ID        = "<Your Access Key ID>";
      my $AWS_SECRET_ACCESS_KEY    = "<Your Secret Access Key>";
      use Amazon::SQS::Client; 
      my $service = Amazon::SQS::Client->new($AWS_ACCESS_KEY_ID, $AWS_SECRET_ACCESS_KEY);

      Make sure the following lines are commented out.

      use Amazon::SQS::Mock;  
      my $service = Amazon::SQS::Mock->new;
    3. Save the file.

    4. Repeat this procedure for each file in the Samples directory.

[Note]Note

The mock service is an alternate way to use the sample code. The service doesn't call AWS, but instead returns a set response that you can modify to suit your needs (the XML response files are in the Mock directory). The mock service makes it easy for you to test how your application handles different responses.

PHP5

To prepare the sample files

  1. Go to the location of the PHP sample code that AWS provides and download the sample code package.

  2. Extract the sample code into a directory on your machine.

  3. Open the amazon-queue-2009-02-01-php5-library/src/Amazon/SQS/Samples/.config.inc.php file.

  4. Enter your Access Key ID and Secret Access Key in the following lines and save the file.

    define('AWS_ACCESS_KEY_ID', '<Your Access Key ID>');
    define('AWS_SECRET_ACCESS_KEY', '<Your Secret Access Key>');
  5. Prepare each of the individual samples:

    1. Open the amazon-queue-2009-02-01-php5-library/src/Amazon/SQS/Samples/CreateQueueSample.php file.

    2. Make sure the following line is not commented out.

      $service = new Amazon_SQS_Client(AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY);

      Make sure the following line is commented out.

      $service = new Amazon_SQS_Mock();
    3. Save the file.

    4. Repeat this procedure for each file in the Samples directory.

[Note]Note

The mock service is an alternate way to use the sample code. The service doesn't call AWS, but instead returns a set response that you can modify to suit your needs (the XML response files are in the Mock directory). The mock service makes it easy for you to test how your application handles different responses.