You can call this operation to send messages from a producer to a Message Queue for Apache RocketMQ broker.
Request structure
Request line
POST /topics/TopicName/messages?ns=INSTANCE_ID HTTP/1.1
The following table describes the parameters in the request line.
Parameter
Required
Description
TopicName
Yes
The name of the destination topic to which you want to send messages.
ns
No
The ID of the instance. This parameter is required for new instances that have namespaces. You can check whether your instance has a namespace on the Instances page in the Message Queue for Apache RocketMQ console. Instances are classified into default instances and new instances based on whether they have namespaces.
Default instance: A default instance does not have a namespace. The names of all resources in a default instance must be globally unique.
New instance: A new instance has a namespace. The names of all resources in a new instance must be unique within the instance.
For more information about namespaces for Message Queue for Apache RocketMQ instances, see Use instances.
Request body (XML format)
The following table describes the parameters in the request body.
Parameter
Required
Description
MessageTag
No
The tag of the message.
MessageBody
Yes
The content of the message.
Properties
No
The properties of the message.
The following information describes the key-value pairs in the serialized properties of the message:
Specify the key-value pairs in the following format:
key1:value1|key2:value2|key3:value3
.The following table describes the parameters that are used to specify the key-value pairs.
Parameter
Type
Description
KEYS
String
The key of the message.
__STARTDELIVERTIME
Long
The absolute scheduled time of a scheduled message. Set this parameter to a UNIX timestamp that represents the number of milliseconds.
__TransCheckT
Long
The relative time when you want to perform the first status check for a transactional message. Unit: seconds. Valid values: 10 to 300.
Response structure
Status line
HTTP/1.1 201
Response body
The following table describes the parameters in the response body.
Parameter
Type
Description
MessageId
String
The ID of the message.
MessageBodyMD5
String
The MD5 hash value of the message body.
Examples
Sample requests
<?xml version="1.0" encoding="UTF-8"?> <Message xmlns="http://mq.aliyuncs.com/doc/v1/"> <MessageBody>a</MessageBody> <MessageTag>Tag</MessageTag> <Properties>KEYS:MessageKey|__STARTDELIVERTIME:1571388173000</Properties> </Message>
Sample responses
<Message xmlns="http://mq.aliyuncs.com/doc/v1/"> <MessageId>1E057D566EAD42A579935B5CD874****</MessageId> <MessageBodyMD5>0CC175B9C0F1B6A831C399E26977****</MessageBodyMD5> </Message>