Send messages
Put a message on a queue, or up to ten in one request, with attributes, a delay, or a FIFO message group.
Replace my-queue with the name of your queue.
A message has a body of text (not empty; no control characters other than tab, line feed and
carriage return) and up to 10 attributes, name–value string pairs whose names are letters, digits,
_, . or -. Its size is the body plus the attributes' names and values in UTF-8 bytes, and
must not exceed the queue's maximum message size (256 KiB on a new queue).
Prerequisites
- Permission for
queue:SendMessageon the queue. The batch send needs the same action. For the console, alsoqueue:GetQueueAttributeson it, to open its page.
Send a message
- Open the queue, then choose Send and receive (or Send a message at the top of the queue's page).
- Under Send a message, for Body, enter the message.
- (Optional) For Attributes, enter one
key=valueper line, up to ten. - On a standard queue, for Delay, enter the seconds before the message can be received (0 to 900). The field starts at 0 and is always sent, so a console send does not use the queue's delivery delay unless you enter it here. On a FIFO queue, for Message group, enter the group, and for Deduplication id, enter an id (optional when the queue has content-based deduplication).
- Choose Send.
The section shows Sent with the message id, and on a FIFO queue its sequence number. A FIFO send
that repeats a recent deduplication id shows Duplicate of the original message instead.
dcloud queue messages send my-queue --body '{"orderId": 42}' --attributes type=order.createdOn a FIFO queue, add --message-group-id and, unless the queue has content-based deduplication,
--message-deduplication-id.
POST /queue/api/queues/my-queue/messages
{ "body": "{\"orderId\": 42}", "attributes": { "type": "order.created" }, "delaySeconds": 10 }The answer is 201 with messageId, md5OfBody, sentAt, sequenceNumber (FIFO only, else
null) and duplicate.
Up to 10 messages in one request, each with an id of your choosing, unique in the batch:
POST /queue/api/queues/my-queue/messages/batch
{ "entries": [ { "id": "a", "body": "first" }, { "id": "b", "body": "second" } ] }The answer is 201 with successful (one entry per message sent, with its id) and failed
(id, code and error for each entry not sent). An entry that fails on its own, for example
one too large for the queue, does not stop the others.
Not available in Terraform. Sending a message is an action, not configuration.
To send from an SQS client, use SendMessage or SendMessageBatch; see
Use an SQS client.
Result
The message is stored and can be received once its delay, if any, has passed. A delay given with a send overrides the queue's delivery delay for that message.
When a send is refused
400"Message is 70000 bytes; this queue accepts at most 65536." when the message is larger than the queue's maximum message size (here set to 64 KiB). In a batch, that entry fails alone.400"The batch is 300000 bytes; a batch may carry at most 262144." when the messages of one request together exceed 256 KiB, a single message over 256 KiB included. The whole batch is refused.403with codeOverLimitwhen the queue would hold more than 100,000 messages, or your organization's queues more than 1 GiB of messages. The whole batch is refused. The counts are a few seconds old, so a burst can go slightly over before sends are refused. See Quotas.400"MessageDeduplicationId applies only to FIFO queues." on a standard queue. A message group is ignored there.- On a FIFO queue:
400"The request must contain the parameter MessageGroupId." without a group; "DelaySeconds is not valid per message on a FIFO queue; set the delay on the queue instead." with a delay; and "The queue should either have ContentBasedDeduplication enabled or MessageDeduplicationId provided explicitly." without a deduplication id on a queue without content-based deduplication.