A message contains data and attributes. The MessageId and ReceiptHandle are both unique and can identify a message in a queue.
Messages are classified into normal messages and delayed messages.
A normal message can be consumed immediately after being sent to a message queue.
A delayed message only can consumed after preset dalay duration since being sent to a delayed message queue.The delay duration is determined by the DelaySeconds parameter (Refer to
A normal message sent to a delayed message queue cannot be acquired before expiry of the delay period (for details, see queue-related descriptions).
- MessageId is used to identify a message in a queue.
- Every message in one queue has a unique MessageId.
- MessageIds in different message queues may be the same.
A MessageId is generated when sending the message and returned in response.It is mainly used for data validation. To delete the message, you need to use ReceiptHandle.
ReceiptHandle is a temporary message identifier generated by MNS when a message is consumed to distiguish from MessageId.
To delete a consumed message or change the Visiblity Timeout attribute value, you need to use ReceiptHandle to specify the message.
ReceiptHandle can be used only once and become invalid if the status of the idenfied message changes, which lead the consumer to get a new ReceiptHandle by consuming the message again.
The initial status of a message is Active after it is sent to a normal queue.
After being consumed from the queue, the message is Inactive during the VisibilityTimeout period.
The status of the message switches to Active again if is not deleted after the VisibilityTimeout period expires; while it becomes as Delete if the message is deleted within the VisibilityTimeout period.
When a normal message is sent to a delayed queue, the initial status of the message is Delayed.Upon expiry of the time specified by DelaySeconds of the delayed queue, the message status changes to Active.
When a delayed message is sent to a message queue (a normal message queue or a delayed message queue), the initial status of the message is Delayed.Upon expiry of the time specified by DelaySeconds, the message status changes to Active.
The maximum lifetime of a message is determined by the MessageRetentionPeriod attribute value specified during creation of the queue. Upon expiry of MessageRetentionPeriod, the message status changes to Expired, and the message will be reclaimed by the garbage collector.
The consumer can only consume messages in Active status.