tencent cloud

文档反馈

CreateSubscribe

最后更新时间:2020-05-09 10:25:45

1. API Description

Domain name for API request: cmq.tencentcloudapi.com.

This API is used to create a subscription.

A maximum of 20 requests can be initiated per second for this API.

Note: This API supports Finance regions. If the common parameter Region is a Finance region, a domain name with the Finance region needs to be specified, for example: cmq.ap-shanghai-fsi.tencentcloudapi.com

2. Input Parameters

The following request parameter list only provides API request parameters and some common parameters. For the complete common parameter list, see Common Request Parameters.

Parameter Name Required Type Description
Action Yes String Common parameter. The value used for this API: CreateSubscribe.
Version Yes String Common parameter. The value used for this API: 2019-03-04.
Region Yes String Common parameter. For more information, please see the list of regions supported by the product.
TopicName Yes String Topic name, which is unique under the same account in an individual region. It is a string of up to 64 characters, which must begin with a letter and can contain letters, digits, and dashes (-).
SubscriptionName Yes String Subscription name, which is unique in the same topic under the same account in an individual region. It is a string of up to 64 characters, which must begin with a letter and can contain letters, digits, and dashes (-).
Protocol Yes String Subscription protocol. Currently, two protocols are supported: http and queue. To use the http protocol, you need to build your own web server to receive messages. With the queue protocol, messages are automatically pushed to a CMQ queue and you can pull them concurrently.
Endpoint Yes String Endpoint for notification receipt, which is distinguished by Protocol. For http, Endpoint must begin with http:// and host can be a domain name or IP. For Queue, enter QueueName. Please note that currently the push service cannot push messages to a VPC; therefore, if a VPC domain name or address is entered for Endpoint, pushed messages will not be received. Currently, messages can be pushed only to the public network and basic network.
NotifyStrategy No String CMQ push server retry policy in case an error occurs while pushing a message to Endpoint. Valid values: 1. BACKOFF_RETRY: backoff retry, which is to retry at a fixed interval, discard the message after a certain number of retries, and continue to push the next message; 2. EXPONENTIAL_DECAY_RETRY: exponential decay retry, which is to retry at an exponentially increasing interval, such as 1s, 2s, 4s, 8s, and so on. As a message can be retained in a topic for one day, failed messages will be discarded at most after one day of retry. Default value: EXPONENTIAL_DECAY_RETRY.
FilterTag.N No Array of String Message body tag (used for message filtering). The number of tags cannot exceed 5, and each tag can contain up to 16 characters. It is used in conjunction with the MsgTag parameter of (Batch)PublishMessage. Rules: 1. If FilterTag is not set, no matter whether MsgTag is set, the subscription will receive all messages published to the topic; 2. If the FilterTag array has a value, only when at least one of the values in the array also exists in the MsgTag array (i.e., FilterTag and MsgTag have an intersection) can the subscription receive messages published to the topic; 3. If the FilterTag array has a value, but MsgTag is not set, then no message published to the topic will be received, which can be considered as a special case of rule 2 as FilterTag and MsgTag do not intersect in this case. The overall design idea of rules is based on the intention of the subscriber.
BindingKey.N No Array of String The number of BindingKey cannot exceed 5, and the length of each BindingKey cannot exceed 64 bytes. This field indicates the filtering policy for subscribing to and receiving messages. Each BindingKey can contain up to 15 ., i.e., up to 16 phrases.
NotifyContentFormat No String Push content format. Valid values: 1. JSON, 2. SIMPLIFIED, i.e., the raw format. If Protocol is queue, this value must be SIMPLIFIED. If Protocol is http, both options are acceptable, and the default value is JSON.

3. Output Parameters

Parameter Name Type Description
SubscriptionId String SubscriptionId
RequestId String The unique request ID, which is returned for each request. RequestId is required for locating a problem.

4. Example

Example1 Creating subscription

Input Example

https://cmq.tencentcloudapi.com/?Action=CreateSubscribe
&TopicName=ConnTopic&SubscriptionName=ConnSubQueue&Protocol=queue&Endpoint=queue_sub
&<Common request parameters>

Output Example

{
  "Response": {
    "SubscriptionId": "subsc-39gyuuhd",
    "RequestId": "1620b635-6071-47c7-ac1e-975afe5104a7"
  }
}

5. Developer Resources

API Explorer

This tool allows online call, signature authentication, SDK code generation and quick search of APIs to greatly improve the efficiency of using TencentCloud APIs.

SDK

TencentCloud API 3.0 integrates SDKs that support various programming languages to make it easier for you to call APIs.

Command Line Interface

6. Error Code

The following only lists the error codes related to the API business logic. For other error codes, see Common Error Codes.

Error Code Description
FailedOperation Operation failed.
FailedOperation.TryLater The operation is in progress. Please try again later.
InvalidParameter Invalid parameter.
InvalidParameterValue.NoTaskId The task ID does not exist.
LimitExceeded The quota limit is exceeded.
ResourceInUse The resource is in use.
ResourceNotFound The resource does not exist.
ResourceUnavailable The resource is unavailable.
ResourcesSoldOut The resources have been sold out.
UnauthorizedOperation Unauthorized operation.
联系我们

联系我们,为您的业务提供专属服务。

技术支持

如果你想寻求进一步的帮助,通过工单与我们进行联络。我们提供7x24的工单服务。

7x24 电话支持