All Products
Search
Document Center

:What are the maximum number and size of messages managed in batches?

Last Updated:Oct 22, 2024

Simple Message Queue (SMQ, formerly MNS) provides APIs for sending and receiving messages in batches. This reduces costs, because the APIs can handle more queries per second (QPS) and fewer requests.

Batch send messages

The BatchSendMessage API can send a maximum of 16 messages at a time, with the total size not exceeding 64 KB.

  • By default, messages are Base64-encoded. A Base64-encoded message body is larger than the original message body. Therefore, the total size of the original messages cannot exceed 47 KB.

  • Alternatively, you can run the following command to send the original message body:

    message.setMessageBody("message_body", Message.MessageBodyType.RAW_STRING);
  • To send a message larger than 64 KB, see Transmit oversized messages.

Batch receive messages

The BatchReceiveMessage API can receive a maximum of 16 messages at a time. However, in some cases, the number of received messages is smaller than the number of available messages even if the upper limit has not been reached.

Assume that 10 messages (m1, m2, m3, m4, m5, m6, m7, m8, m9, and m10) are sent in order. When you call the BatchReceiveMessage API for the first time, you receive only five messages (m2, m4, m6, m8, and m10). Then, when you call the BatchReceiveMessage API for the second time, you receive the other five messages (m1, m3, m5, m7, and m9).

This is because SMQ stores data on multiple nodes, but each batch operation receives data from only a single node rather than across the nodes. Therefore, the messages received in each batch are determined by the storage node and may not be in order. To specify the order of messages, such as first-in, first-out (FIFO), you need to adjust the architecture at the application layer. For more information, see Ensure the ordering of queue messages.