Getting started
Let's perform the basic actions using the AWS CLI, one of the tools for working with Message Queue.
-
Install the AWS CLI, a command line utility for working with Message Queue.
-
Create a service account with the
editor
role. -
Create static access keys. Save the ID and secret access key right away. You won't be able to view the secret access key parameters again after you close the window.
-
Set up the AWS CLI.
AWS CLISet the AWS CLI configuration via the
aws configure
command, using the ID and secret access key of the service account:$ aws configure AWS Access Key ID [****************kzJl]: <ID of the service account's access key AWS Secret Access Key [****************I3AO]: <ID of the service account's access key Default region name [eu-west-1]: ru-central1 Default output format [None]:
-
Create a queue named
sample-queue
:AWS CLIManagement console$ aws sqs create-queue --queue-name sample-queue \ --endpoint https://message-queue.api.cloud.yandex.net/ { "QueueUrl": "https://message-queue.api.cloud.yandex.net/aoeaql9r10cd9cfue7v6/000000000000002n034r/sample-queue" }
-
Open the Message Queue section.
-
Click Create queue.
-
Specify the queue name:
sample-queue
.The name may contain lowercase Latin letters, numbers, hyphens, and underscores. The name of a FIFO queue must end with the
.fifo
suffix. The name can't be longer than 80 characters. -
Select the Standard type. Do not change other settings.
-
Click Create queue.
-
-
Send a message to the created queue using the queue URL from the
QueueUrl
parameter that can be found in the response to the previous request:AWS CLI$ aws sqs send-message --message-body "Hello World!" \ --endpoint https://message-queue.api.cloud.yandex.net/ \ --queue-url https://message-queue.api.cloud.yandex.net/aoeaql9r10cd9cfue7v6/000000000000002l034r/sample-queue { "MD5OfMessageBody": "67e63db14341b5a696596634bbf19796", "MessageId": "765ff4d2-fa4bc83-6cfcc68e-21a49" }
-
Accept the message from the queue:
AWS CLI$ aws sqs receive-message \ --endpoint https://message-queue.api.cloud.yandex.net/ \ --queue-url https://message-queue.api.cloud.yandex.net/aoegtvhtp8ob9rqq8sto/000000000000002p01jp/sample-queue { "Messages": [ { "MessageId": "948de7-9ec8d787-cbf3465c-c", "ReceiptHandle": "EAEggbjIg_8sKAM", "MD5OfBody": "ed076287532e86365e841e92bfc50d8c", "Body": "Hello World!", "Attributes": { "ApproximateFirstReceiveTimestamp": "1545927269377", "ApproximateReceiveCount": "1", "SentTimestamp": "1545922344034" } } ] }
-
Delete the message from the queue.
After messages are processed, they should be deleted from the queue so that applications do not process them again.
To delete the received message from the queue, use the
ReceiptHandle
parameter value from the response to the previous request:AWS CLI$ aws sqs delete-message \ --endpoint https://message-queue.api.cloud.yandex.net/ \ --queue-url https://message-queue.api.cloud.yandex.net/aoegtvhtp8ob9rqq8sto/000000000000002p01jp/sample-queue \ --receipt-handle EAEggbjIg_8sKAM
-
Delete the queue:
AWS CLIManagement console$ aws sqs delete-queue \ --queue-url https://message-queue.api.cloud.yandex.net/aoegtvhtp8ob9rqq8sto/000000000000002p01jp/sample-queue \ --endpoint https://message-queue.api.cloud.yandex.net/
- Open the Message Queue section.
- Click in the row of the queue to delete.
- In the menu that opens, click Delete.
- In the window that opens, click Delete.