Mi Galaxy EMQ Book

receiveMessage()


Receive Message from queue

parameter ReceiveMessageRequest

queueName : String : required
tagName : String : optional

Specifies the tag to receive in this request. If this value is not set, it is received from the Queue's default tag

maxReceiveMessageNumber : int : optional

Maximum number of message received
The request will be returned immediately when there is a message that may be read in the queue. Therefore, the actual number of messages received is always less than or equal to this value

If this parameter is not set in the request, the queue parameter is used
Queue Default Value: 100
Legal Range: [1, 100]

maxReceiveMessageWaitSeconds : int : optional

See createQueue()

If this parameter is not set in the request, the queue parameter is used
Queue Default Value: 0
Legal Range: [0, 20]

attributeName : String : optional
attributeValue : MessageAttribute : optional

The attributeName and attributeValue can be used to filter messages by custom attributes when they are received. (The custom attribute of the message is defined in sendMessage())
If these two parameters are not set, all messages are received.
If attributeName is specified at the same time, the field type in attributeValue is set to "empty", indicating that all messages containing attributesName (case-sensitive) attribute are received.
Otherwise, only those messages for which attributeName, attributeValue.type, and attributeValue.value are matched will be received.
(For the specific fields of the MessageAttribute type, see sendMessage())
Note: The user can similarly specify filter conditions when createTag(). For the difference between the two, see FAQ.

return List< ReceiveMessageResponse >

Returned message list. Among which ReceiveMessageResponse specifically includes:

messageID : String

The message identifier, corresponding to the return value of SendMessage

receiptHandle : String

Receives a handle to change the invisible time of a message that is received or to delete a message
Messages received are not deleted immediately after use, and will become readable and received again. At this time, the same messageid is received twice but the receiptHandles are different

messageBody : String

Message body

attributes : Map< String, String >

The meta property of the message that contains some of the items in the following
Note Items 8~12 are unique to the dead letter queue

  1. senderId:The developerid of the user who sent the message
  2. messageLength: The length of the messageBody
  3. md5OfBody: messageBody's MD5 checksum
  4. sendTimestamp: The timestamp of the message arriving at the EMQ server
  5. receiveTimestamp: The timestamp of the message leaving the EMQ server for this receipt
  6. firstReceiveTimestamp:When this message is first received, a timestamp for the message leaving the EMQ server
  7. receiveCount: Indicates the total number of times this message was received, including the current receipt. If this value is often greater than 1, and this is not deliberately done by the user, consider increasing invisibilitySeconds
  8. sourceQueueName: Name of source queue
  9. sourceTag: After the message was received in the source Queue with this tag, the redrive condition expires
  10. deadTimestamp: The time at which the message was declared dead in the source queue (no longer received by the corresponding tag from the source queue)
  11. originalMessageID: The original MessageID of the message, that is, the MessageID in the source queue
  12. originalReceiveCount: The number of times the message was received in the original queue
  13. topic: The topic attribute of the Message. See TopicQueue for details.
  14. priority: The priority of the message, see PriorityQueue
messageAttributes : Map< String, MessageAttribute >

For details of the user-defined attributes that are included with sendMessage, see sendMessage().