All Products
Search
Document Center

Message Service:QueueMessage

Last Updated:Dec 25, 2023

QueueMessage specifies messages that are sent to Message Service (MNS) queues. You can specify the body, delay period, and priority of a message when you send the message to an MNS queue. This topic describes the parameters, types, and status of queue messages.

Parameters

  • MessageId

    • The ID of the message.

    • This parameter is returned when you call the SendMessage, BatchSendMessage, ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

    • Each message in a queue has a unique message ID.

    • When you send a message to a queue, MNS generates an ID for the message. After a message ID is generated, it cannot be changed. You can use the message ID for data verification.

  • NextVisibleTime

    • The time when the message can be consumed. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, or ChangeMessageVisibility operation.

  • ReceiptHandle

    • The receipt handle of the message.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, or ChangeMessageVisibility operation.

    • You can use the receipt handle of a message to modify or delete the message that is in the Inactive state. The receipt handle is valid before the time that is specified by the NextVisibleTime parameter. If you use the receipt handle after the specified time, MNS returns the MessageNotExist error message.

    • Each receipt handle can be used only once. If the status of the message that is identified by the receipt handle changes, the receipt handle expires.

  • MessageBody

    • The body of the message.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

  • MessageBodyMD5

    • The MD5 hash of the message body.

    • This parameter is returned when you call the SendMessage, BatchSendMessage, ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

  • EnqueueTime

    • The time when the message was sent to the queue. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

  • FirstDequeueTime

    • The time when the message was first consumed. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

    • If a message has never been consumed, the value of this parameter is the same as the value of the EnqueueTime parameter.

  • DequeueCount

    • The total number of times that the message was consumed.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

  • Priority

    • The priority of the message. Valid values: 1 to 16. The value 1 indicates the highest priority.

    • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.

    • If a queue contains messages with different priorities, the messages with higher priorities can be consumed earlier when you call the ReceiveMessage operation.

    • MNS does not guarantee the order in which messages are consumed due to the data striping feature.

Message Types

Delayed messages

  • After delayed messages are sent to a queue, the messages cannot be consumed until the period that is specified by the DelaySeconds parameter ends.

  • You can specify the DelaySeconds parameter for the queue. You can also specify the DelaySeconds parameter when you call the SendMessage or BatchSendMessage operation.

Message status

  • When a standard message is sent to a standard queue, the message is in the Active state. After the message is received, the message enters the Inactive state. The message remains in the Inactive state within the period that is specified by the VisibilityTimeout parameter. If the message is not consumed within the specified period, the message enters the Active state. If the message is deleted within the specified period, the message enters the Deleted state.

  • When a standard message is sent to a delayed queue, the message is in the Delayed state. After the period that is specified by the DelaySeconds parameter ends, the message enters the Active state.

  • When a delayed message is sent to a queue, the message is in the Delayed state. After the period that is specified by the DelaySeconds parameter ends, the message changes to the Active state.

  • The maximum period of time for which a message can be retained in a queue is specified by the MessageRetentionPeriod parameter. After the specified period ends, the message enters the Expired state. Then, the message is recycled by the garbage collector.

  • Only messages in the Active state can be received.