You can call this operation to send messages from a producer to a Message Queue for Apache RocketMQ (RocketMQ) broker.

Request structure

  • Request line

    POST /topics/TopicName/messages? ns=INSTANCE_ID HTTP/1.1

    The following table lists the parameters in the request line.

    Parameter Required Description
    TopicName Yes The name of the destination topic to which a message is sent.
    ns No The instance ID. It is required for a new instance with a namespace. You can check whether the instance has a namespace on the Instances page of the console. Instances are classified into default instances and new instances depending on whether they have namespaces.
    • Default instance: has no namespace. All resource names in this default instance must be globally unique.
    • New instance: has a namespace. The resource names must be unique within this instance.
    For more information, see Updates.
  • Request content (XML format)

    The following table lists the parameters in the request content.

    Parameter Required Description
    MessageTag No The message tag.
    MessageBody Yes The message content.
    Properties No The properties of the message.

    The following describes the key values in the serialized properties of the message:

    • Format: key1:value1|key2:value2|key3:value3
    • The following table lists the key values.
      Parameter Type Description
      KEYS String The message key.
      __STARTDELIVERTIME Long The absolute scheduled time of a scheduled message. Unit: milliseconds in UNIX.
      __TransCheckT Long The relative time for checking the first transactional message. Unit: seconds. Valid values: 10 to 300.

Response structure

  • Status line

    HTTP/1.1 201

  • Response content

    The following table lists the parameters in the response content.

    Parameter Type Description
    MessageId String The message ID.
    MessageBodyMD5 String The MD5 value of the message content.

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>