QueueMessage

更新时间:
复制 MD 格式

A QueueMessage is a message that is sent to a queue. When you send a message, you can specify its body, delay duration, and priority. This topic describes the attributes, types, and statuses of queue messages.

Message attributes

  • MessageId

    • The message ID.

    • The send message, receive message, and peek message operations, including batch operations, return this property.

    • Each message in a queue has a unique MessageId.

    • When a message is sent to a queue, Simple Message Queue (formerly MNS) generates a MessageId. This ID is immutable and can be used for data verification.

  • NextVisibleTime

    • The time at which the message can be consumed next. This is measured in milliseconds from 00:00:00 UTC on January 1, 1970.

    • The receive message and change message visibility operations, including batch operations, return this property.

  • ReceiptHandle

    • Receipt handle.

    • The receive message and change message visibility operations, including batch operations, return this property.

    • You can use this handle to delete a message or change its visibility while it is in the Inactive state. The handle is valid until the time specified by NextVisibleTime. If you use the handle after this time, MNS returns a MessageNotExist error.

    • The receipt handle can be used only once and becomes invalid if the status of the message changes.

  • MessageBody

    • The message content.

    • This property is returned by the receive message and peek message operations.

  • MessageBodyMD5

    • The MD5 hash of the message content.

    • The send message, receive message, and peek message operations, including batch operations, return this property.

  • EnqueueTime

    • The time at which the message was sent to the queue. This is measured in milliseconds from 00:00:00 UTC on January 1, 1970.

    • This property is returned by the receive message and peek message operations.

  • FirstDequeueTime

    • The time at which the message is first consumed, measured in milliseconds from 00:00:00 UTC on January 1, 1970.

    • The receive message and peek message operations, including batch operations, return this property.

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

  • DequeueCount

    • The total number of times a message has been dequeued.

    • The receive message and peek message operations, including batch operations, return this property.

  • Priority

    • The priority of the message. The value is an integer from 1 to 16, where 1 is the highest priority.

    • The receive message and peek message operations, including batch operations, return this property.

    • If a queue contains messages with different priorities, higher-priority messages are more likely to be consumed first by the ReceiveMessage operation.

    • Simple Message Queue (formerly MNS) attempts to dequeue high-priority messages first. However, because of the distributed nature of message queues, it cannot guarantee that high-priority messages are always consumed first.

Message type

Delayed message

  • After a delayed message is sent to a queue, it can be consumed only after the delay period specified by the DelaySeconds property has passed.

  • You can specify this value in a send message request, including batch requests, or by configuring the DelaySeconds property of the queue.

Message status

  • When a normal message is sent to a standard queue, its initial status is Active. After the message is retrieved, its status changes to Inactive for the duration of the VisibilityTimeout period. If the message is not deleted within this period, its status reverts to Active. If the message is deleted within the VisibilityTimeout period, its status changes to Deleted.

  • When a normal message is sent to a delayed queue, its initial status is Delayed. After the delay period specified by the queue's DelaySeconds property passes, the message status changes to Active.

  • When a delayed message is sent to a queue, which can be a standard or delayed queue, its initial status is Delayed. After the delay period specified by the message's DelaySeconds property passes, its status changes to Active.

  • The maximum time to live for a message is determined by the MessageRetentionPeriod property, which is set when the queue is created. After this period expires, the message status changes to Expired and is then removed by the garbage collector.

  • Consumers can only retrieve messages that are in the Active state.