This topic describes the parameters, types, and statuses of queue messages.

Queue messages

Queue messages refer to the 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.

Parameters

MessageId
  • The ID of the message.
  • This parameter is returned when you call the SendMessage, BatchSendMessage, ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.
  • In a queue, each message 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. The value is a timestamp that follows the UNIX time format. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  • 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. The value is a timestamp that follows the UNIX time format. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  • This parameter is returned when you call the ReceiveMessage, BatchReceiveMessage, PeekMessage, or BatchPeekMessage operation.
FirstDequeueTime
  • The first time when the message was consumed. The value is a timestamp that follows the UNIX time format. It is the number of milliseconds that have elapsed since 00:00:00 Thursday, January 1, 1970.
  • 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 for which 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 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 statuses

  • When a standard message is sent to a standard queue, the message is in the Active state. After the message is received, the message changes to 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 changes to the Active state. If the message is deleted within the specified period, the message changes to 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 changes to 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 for which a message can retain in a queue is specified by the MessageRetentionPeriod parameter. After the specified period, the message changes to the Expired state. Then, the message is recycled by the garbage collector.
  • Only messages in the Active state can be received.