Mi Galaxy EMQ Book

sendMessage()


Send message to Queue, cannot send message to Dead Letter Queue.

parameter SendMessageRequest

queueName : String : required
messageBody : String : required

Message content, the message body

delaySeconds : int : optional

Delay time
After the message enters the queue, it becomes visible after a delay, thereby being received by the user
If the value is not set, it uses the value set in the Queue
Queue Default Value: 0
Legal Range: [0, 900]

invisibilitySeconds : int : optional

Invisible time
After the message is received by the user, if not deleted by the user in time, it will be changed to visible after the invisible time
If no value is set, it uses the value set in the Queue
Queue Default Value: 30
Legal Range: [2, 43200]

messageAttributes : Map< String, MessageAttribute > : optional

Message with user-defined attribute Map
The attribute name is String type, and the attribute value is MessageAttribute type
The size of these attributes is also included in the message's overall size, which is commonly limited by the Queue attribute messageMaximumBytes.

Fields of type MessageAttribute type include:

  1. type : String : required
  2. stringValue : String : optional
  3. binaryValue : byte[] : optional

Type is the type of attribute, currently supports both <string and binary
Users can append their own subtypes after type, such as string.Number,binary.File. Subtypes Transparent to EMQ Services
If type starts with string, it is considered to be of type string, if it starts with binary, it is of type binary. Type can only contain numbers, letters, and periods
stringValue and binaryValue cannot be empty at the same time, and must correspond to type type
For example, if you want to include a picture in the message, you can set the type to binary.JPEG and set the binaryValue to the data of the picture.

Note: DLQ.sourceQueue is a user attribute keyword reserved by the system. Users cannot customize the attributes of this name.

topic : String : optional

Message topic, defaults to empty
See topicqueue for details

priority : int : optional

The priority of the Message; the default is 8, the range is [1, 16]. The priority of the message takes effect only when the Queue is set to allow message priority. See PriorityQueue for details

return SendMessageResponse

messageID : String

The string used to uniquely identify the message. The messageID of different messages in the same Queue will not be the same

bodyLength : int

The length of the Message body. That includes only the length of the messageBody

bodyMd5 : String

Message body MD5 checksum

sendTimestamp : long

The timestamp of the message arriving at the EMQ server

sendMessageBatch()


Send multiple messages to the Queue at once (usually no more than 10) This operation is currently an atomic operation by default. That is, multiple send messages either succeed at the same time or fail at the same time

parameter SendMessageBatchRequest

queueName : String : required
sendMessageBatchRequestEntryList : List< SendMessageBatchRequestEntry > : required

For the send message list, every element is one message

SendMessageBatchRequestEntry specifically includes:

  1. entryId : String : required
  2. messageBody : String : required
  3. delaySeconds : int : optional
  4. invisibilitySeconds : int : optional
  5. priority : int : optional
  6. messageAttributes : Map< String, MessageAttribute > : optional

Among which the entryId is used to uniquely identify a message in the entire list, so it cannot be empty or repeated. The return value of the method will use this entryId to index the return information for each message
The meaning of the remaining fields is the same as the corresponding field in SendMessageRequest

topic : String : optional

The topic of all messages in the request defaults to empty
(In this operation, the topic of all messages must be the same)
See TopicQueue for details

return SendMessageBatchResponse

successful : List< SendMessageBatchResponseEntry >

Successful send message return information

SendMessageBatchResponseEntry type includes the following specific fields:

  1. entryId : String
  2. messageID : String
  3. bodyLength : int
  4. bodyMd5 : String
  5. sendTimestamp : long

Among which the entryId corresponds to the entryId in the SendMessageBatchRequestEntry type, and the remaining fields have the same meaning as the corresponding fields in SendMessageResponse.