Sending messages
Written by
Updated at October 28, 2024
Messages are sent through message queues in Message Queue and may contain plain text in the message body. Consumers get messages and delete them from the queue after receiving and processing them.
To send a message to a queue:
-
If you do not have a message queue in Message Queue, create one.
-
Run the following command in the terminal:
AWS CLIcURLaws sqs send-message \ --message-body "<message_text>" \ --endpoint <endpoint> \ --queue-url <queue_URL>
Where:
--message-body
: Text of the message you want to send to the queue, e.g.,Hello World
.--endpoint
: Endpoint in thehttps://message-queue.api.cloud.yandex.net/
value.--queue-url
: URL of the queue the message will be sent to.
Result:
{ "MD5OfMessageBody": "67e63db14341b5a696596634********", "MessageId": "765ff4d2-fa4bc83-6cfcc***-*****" }
curl \ --request POST \ --header 'Content-Type: application/x-www-form-urlencoded' \ --data-urlencode 'Action=SendMessage' \ --data-urlencode 'MessageBody=<message_text>' \ --data-urlencode 'QueueUrl=<message_queue_URL>' \ --user '<access_key_ID>:<secret_key>' \ --aws-sigv4 'aws:amz:ru-central1:sqs' \ https://message-queue.api.cloud.yandex.net/
Where:
--header
: HTTP request headers.--data-urlencode
: Parameters for generating an API request.MessageBody
: Text of the message you want to send to the queue.QueueURL
: URL of the queue the message will be sent to.
--user
: Static key components (ID and secret key).--aws-sigv4
: Parameter for generating AWS-compatible authorization headers.
Result:
<?xml version="1.0" encoding="UTF-8"?> <SendMessageResponse><SendMessageResult><MD5OfMessageBody>fa46dfdbe2396ac930bfa896********</MD5OfMessageBody><MessageId>31bebd6e-5b61e482-7aaaa45a***-*****</MessageId></SendMessageResult><ResponseMetadata><RequestId>7c65c427-be26a31a-cf93dee9-dd4989d8-ab97b54614e49d7fe560b779********</RequestId></ResponseMetadata></SendMessageResponse>