tencent cloud

피드백

Publish news

마지막 업데이트 시간:2020-06-08 16:24:40

    Note:

    This is a legacy API which has been hidden and will no longer be updated. We recommend using the new CMQ API 3.0 which is standardized and faster.

    Interface description

    This API (PublishMessage) is used to send a message from publish to the specified topic.

    • Domain name requested by public network API: https://cmq-topic-{$region}.api.qcloud.com
    • Domain name requested by private network API: http://cmq-topic-{$region}.api.tencentyun.com

    The above {$region} in the domain name needs to be replaced with a specific region : gz (Guangzhou), sh (Shanghai), bj (Beijing), shjr (Shanghai Financial), szjr (Shenzhen Financial), hk (China Hong Kong), cd (Chengdu), ca (North American), usw (Maxi), sg (Singapore). The region value in the common parameters should be consistent with the region value of the domain name. If there is any inconsistency, the request will be sent to the region specified by the domain name region based on the region value of the domain name.

    At any time (including during internal testing), if the public network downstream Traffic is generated by using a public network domain name, Traffic and cost will be charged. Therefore, users of the service on Tencent Cloud are strongly recommended to use it. Private network Domain name, private network will not produce Traffic cost.

    Input Parameter

    The following request parameter list only lists the API request parameters. For other parameters, please see Common Request Parameters page.

    Parameter name Required Type Description
    TopicName Yes String Topic's name is unique under the same account in a single region. The name of topic is a string of no more than 64 characters, which must begin with a letter, and the rest can contain letters, numbers and underscores (-).
    MsgBody Yes String Message body. At least 1 byte, the maximum length is limited by the set topic message maximum length attribute.
    MsgTag.n No String Message filter tag. Message label (for message filtering). The number of tags cannot exceed 5, and each label cannot exceed 16 characters. and Subscribe The filterTag parameter of the API is used together. Rules:
    (1) if filterTag is not set, subscriptions receive all messages from publish to Topic, regardless of whether msgTag is set or not.
    (2) if the filterTag array has a value, the subscription will receive the message from publish to Topic only if at least one value in the array also exists in the msgTag array (that is, there is an intersection between filterTag and msgTag).
    (3) if the filterTag array has a value, but msgTag is not set, then no messages from publish to Topic will be received, which can be regarded as a special case of (2). In this case, filterTag and msgTag do not intersect. The overall design idea of the rules is based on the wishes of the subscribers.
    RoutingKey No String Length < = 64 bytes, this field is used to indicate the routing path to send the message, with a maximum of 15 ".", that is, a maximum of 16 phrases.
    RoutingKey cannot be arbitrarily specified when a message is sent to a exchange of type topic. To meet the above format requirements, a message with routingKey specified by the subscriber will be pushed to all consumers with which the BindingKey can match. This matching situation has two relationships:
    1 * (asterisk), which can replace a word (a continuous string of letters);
    2 # (pound sign): can match one or more characters.

    Output Parameter

    Parameter name Type Description
    Code Int 0: indicates success. Others: error. For more information, please see Common error code .
    Message String Error message.
    RequestId String When an internal server error occurs in the request ID, generated by the server, the user can submit this ID to Backend Background to locate the problem.
    MsgId String The server generates a unique identity ID for the message.

    Error Codes

    Please check Common error code .

    Example

    Enter:

    https://domain/v2/index.php?Action=PublishMessage
    &topicName=test-topic-123
    &msgBody=helloworld
    &<Common request parameters>
    

    Output:

    {
    "code" : 0,
    "message" : "",
    "requestId":"14534664555",
    "msgId":"123345346"
    }