Skip to main content

Getting started

This walkthrough takes a few minutes: you create a queue, create an access key and exchange the first message with the AWS CLI. The same path works for the SDKs, shown in SDK examples.

Before you start​

You need:

ItemWhy
Access to the NNumbers Console in the right organizationResources belong to the active organization
The Editor role in MessagingTo create the queue
The Admin role in MessagingTo create the access key (or ask an admin)
AWS CLI v2 installedFor the send and receive test

Open Documentation and examples in the Messaging module and check the Queues address and the region. The addresses https://nqs.msg.nnumbers.com.br (Queues), https://nns.msg.nnumbers.com.br (Notifications) and https://nes.msg.nnumbers.com.br (Email) are the planned ones; the page shows the current configuration and whether they are already published.

1. Create the queue​

  1. In the Console, open Messaging and then Queues.
  2. Start creating a new queue.
  3. Choose the Standard type and give it a name, for example orders. The name accepts letters, digits, hyphens and underscores, up to 80 characters.
  4. Keep the default attributes (30 s visibility timeout, 4-day retention) and confirm.

The queue shows up in the list with its URL and ARN. The URL has the format https://nqs.msg.nnumbers.com.br/<account>/orders, where <account> is the organization's 12-digit virtual account.

tip

Want to check the queue before writing code? Send a test message from the queue page. The approximate message count goes up right after.

2. Create the access key​

  1. Open Access credentials and start creating a new key.
  2. Give it a description that identifies the application, for example getting started test.
  3. For this test, you can restrict the key to the orders queue.
  4. Confirm and copy the access key ID and the secret key.
The secret key is shown only once

Store the secret key in a secret manager. It is not shown again; if you lose it, revoke the key and create another one.

3. Send and receive​

Export the credential in the terminal (the value comes from your secret manager and is never written in a script):

export AWS_ACCESS_KEY_ID="$(cat /protected/path/key-id)"
export AWS_SECRET_ACCESS_KEY="$(cat /protected/path/secret-key)"
export AWS_DEFAULT_REGION=br-se-1
ENDPOINT=https://nqs.msg.nnumbers.com.br

Find the queue URL, then send, receive and delete the message:

QUEUE_URL=$(aws sqs get-queue-url --endpoint-url "$ENDPOINT" \
--queue-name orders --query QueueUrl --output text)

aws sqs send-message --endpoint-url "$ENDPOINT" \
--queue-url "$QUEUE_URL" --message-body "order 42 created"

aws sqs receive-message --endpoint-url "$ENDPOINT" \
--queue-url "$QUEUE_URL" --wait-time-seconds 10

aws sqs delete-message --endpoint-url "$ENDPOINT" \
--queue-url "$QUEUE_URL" --receipt-handle "<ReceiptHandle received>"

If the message is not deleted, it becomes visible again when the visibility timeout ends and is delivered again. That is the expected behavior of a queue: delete only after processing.

If something goes wrong​

ErrorLikely cause
InvalidClientTokenIdWrong key ID or revoked key
SignatureDoesNotMatchWrong secret key, a region other than br-se-1, or the machine clock more than 5 minutes ahead or behind
AccessDeniedThe key has action or queue restrictions that do not include this operation or this queue
NonExistentQueueWrong queue name, or the queue belongs to another organization

Next steps​

  • Queues: types, attributes and dead-letter queues.
  • Notifications: fan a message out to several subscribers.
  • Email: verify a domain and send the first email.
  • SDK examples: Java, Python, Node.js and the AWS CLI.