Create a subscription

Last updated: 2020-06-08 16:27:20


    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 (Subscribe) is used to create a new subscription under a user named topic.

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

    The above {$region} in the domain name needs to be replaced with a specific region : gz (Guangzhou), sh (Shanghai), bj (Beijing), shjr (Shanghai Finance), szjr (Shenzhen Finance), hk (Hong Kong, China), cd (Chengdu), ca (North America), usw (American West), 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, it is strongly recommended that users of the service on Tencent Cloud use 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. Topic's name is a string of no more than 64 characters, which must begin with a letter, and the rest can contain letters, numbers and underscores. - .
    SubscriptionName Yes String The subscription name is unique under the same topic of the same account in a single region. The subscription name is a string of no more than 64 characters, which must begin with a letter, and the rest can contain letters, numbers, and dashes. - .
    Protocol Yes String Protocol, who subscribes to, currently supports two kinds of Protocol: HTTP and queue. With HTTP Protocol, users need to build their own Web Server to accept messages. Using queue, messages will be automatically pushed to CMQ queue, users can pull messages Concurrence.
    Endpoint Yes String The endpoint, that receives shipping's message is distinguished according to Protocol's protocol:
    (1) for HTTP,endpoint, you must use http:// In the beginning, host can be a domain name or a IP,endpoint with a maximum length of 500, Currently, the push service cannot be pushed to VPC. Therefore, endpoint Enter will not receive push messages for VPC domain name or address. Currently, push is supported to public network and basic network.
    (2) enter queueName for queue,.
    NotifyStrategy No String The retry policy of the endpoint push server when an error occurs in the push message to CMQ. There are two values:
    (1) BACKOFF_RETRY, Backoff retry. Every other [ 19] s try again, after 3 retries, discard the message and continue to push the next message.
    (2) EXPONENTIAL_DECAY_RETRY, index decline retry. The interval of each retry increases exponentially, for example, at the beginning of 1s, followed by 2s, 4s, 8s. Because the cycle of Topic messages is one day, at most one day of retry will discard the message. The default value is EXPONENTIAL_DECAY_RETRY.
    NotifyContentFormat No String The format of the push content. Value: (1) JSON. (2) SIMPLIFIED, is raw format. If protocol is Queue, the value must be SIMPLIFIED. If protocol is HTTP, both values can be used, and the default value is JSON.
    FilterTag.n No String Message body. Message label (for message filtering). The number of tags cannot exceed 5, and each label cannot exceed 16 characters. and (Batch) PublishMessage The msgTag parameter is used together, and the rules are as follows:
    (1) if filterTag is not set, the subscription receives 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 publish to Topic message only if at least one value in the array also exists in the msgTag array (that is, filterTag and msgTag intersect).
    (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.

    Output Parameter

    In the case of success, all output parameters are returned to the user; in the case of failure, at least code, message, and requestId are returned.

    Parameter name Type Description
    Code Int 0: indicates success, others: error. The detailed error is shown in the following table.
    Message String Error message.
    RequestId String Request ID generated by the server. When an internal error occurs on the server, the user can submit this ID to Backend Background to locate the problem.

    Error Codes

    The following are the error codes specific to the interface. If the error code you are looking for is not among them, it may be found in the Common error code Medium.

    Error codeModule error codeEnglish hintDescription
    449010470Subscribtion is already existedUnder the same Topic of the same account, the subscription with the same name already exists.
    450010480Number of subscription has reached the limitThe number of subscriptions under the same Topic exceeds the limit. Currently, the maximum number of subscriptions is 100.
    400010490Number of filterTag exceed limitThe number of filterTag exceeds the limit. At present, the maximum number is five.
    400010500Endpoint format errorEndpoint format error.
    Possible errors are: (1) url contains spaces; (2) the url of HTTP does not start with "http://"; (3) illegal url; (4) protocol does not correspond to endpoint.
    400010510Undefined protocolThe undefined Protocol. Please check your spelling.
    400010520Undefined notify retry stragetyUndefined message push retry policy. Please check your spelling.
    400010530Undefined notify content formatUndefined message push format. Please check your spelling.
    451010570Url connot contain any blank charactersUrl cannot contain white space characters.
    400010580Subscription name format errorThe subscription name is in the wrong format.
    400010620Subscription name format errorThe subscription name is in the wrong format.
    400010630Illegal endpointIllegal endpoint.
    400010640NotifyContentFormat of protocol queue must be SIMPLIFIEDWhen the protocol field is queue, notifyContentFormat must be SIMPLIFIED
    605010740Too many filterTagThere are too many filterTag, please check the parameter settings.
    400010670Too many filterTagThe number of filterTag is too large, please check the number of parameters.



     &<Common request parameters>


        "code": 0,
        "message": "",
        "requestId": "14534664555"

    Was this page helpful?

    Was this page helpful?

    • Not at all
    • Not very helpful
    • Somewhat helpful
    • Very helpful
    • Extremely helpful
    Send Feedback