Updated on 2024-04-19 GMT+08:00

Adding a Subscription

Scenarios

To deliver messages published to a topic to endpoints, you must add the subscription endpoints to the topic. Endpoints can be email addresses, phone numbers, and HTTP/HTTPS URLs. After you add endpoints to the topic and the subscribers confirm the subscription, they are able to receive messages published to the topic.

You can add multiple subscriptions to each topic. This section describes how you can add a subscription to a topic you created or a topic that you have permissions for.

Adding a Subscription

  1. Log in to the management console.
  2. In the upper left corner of the page, click and select the desired region and project.
  3. Click . Select Simple Message Notification under Management & Governance.

    The SMN console is displayed.

  4. In the navigation pane, choose Topic Management > Subscriptions.
  5. In the upper right corner, click Add Subscription.

    The Add Subscription dialog box is displayed.

    Figure 1 Add Subscription
  6. Specify the required subscription information.
    1. Beside the Topic Name box, click Select Topic.
    2. Specify the subscription protocol and endpoints.
      Table 1 Parameters for adding a subscription

      Parameter

      Description

      Topic Name

      Specifies the name of the topic to which messages are published.

      Protocol

      Specifies the protocol over which messages are sent. Possible values include SMS, HTTP, HTTPS, FunctionGraph (function), Voice notification, DingTalk chatbot, WeCom chatbot, Lark chatbot, and Email.

      NOTE:
      • Voice notification, DingTalk chatbot, WeCom chatbot, and Lark chatbot are in the open beta test (OBT). To use these protocols, submit a service ticket to apply for the OBT.
      • After the OBT is enabled, the current IAM user token will be invalid. Log in to the console again to use the token. When calling an API, obtain a new token.
      • The number of WeCom, DingTalk, and Lark messages that can be sent is limited, and the recipient system may be faulty. As a result, messages may fail to be sent.

        In this case, SMN does not ensure successful message delivery.

      Endpoint

      Specifies the subscription endpoint. You can add up to 10 SMS, email, HTTP, or HTTPS endpoints, one in each line.

      • SMS: Enter one or more valid phone numbers.

        Examples:

        18512345678

        +8618512345678

      • Email: Enter one or more valid email addresses.

        Examples:

        username@example.com

        username2@example.com

      • HTTP: Enter one or more public network URLs.

        Example:

        http://example.com/notification/action

      • HTTPS: Enter one or more public network URLs.

        Example:

        https://example.com/notification/action

      • FunctionGraph (function): Click to select a function and specify its version.
      • Voice notification: Enter one or more valid phone numbers.

        The phone number must be preceded by a plus sign (+) and country code. If you enter a phone number used in the Chinese mainland, the plus sign (+) and country code are not required.

        Voice subscriptions are available only in some regions of the Chinese mainland. Voice notification is not supported in Hong Kong, Macao, Taiwan, Xinjiang, and Tibet.

      Request Header

      This parameter is available when you set Protocol to HTTP or HTTPS. It indicates whether to configure the request header immediately. If you select Configure now, you need to specify Key and Value. You can add up to 10 request headers.

      The value of Key must:

      • be case insensitive and unique.
      • start with x- but cannot start with x-smn.
      • contain only digits, letters, and hyphens (-), but not end with a hyphen nor contain consecutive hyphens.

      Availability Test

      This parameter is available when you set Protocol to HTTP or HTTPS. Click Start to check the real-time connectivity between SMN and HTTP/HTTPS endpoints.

      Version

      This parameter is available when you set Protocol to FunctionGraph (function). Select the version of a created FunctionGraph (function). For details about how to create a version, see Version Management.

      Description

      Specifies the remarks of the subscription.

    3. (Optional) Configure a subscription filtering policy to limit the scope of message publishing. The default filtering policy applies to message attributes. If you have set a filtering policy and message attributes when publishing a message, the system determines whether to push the message to the subscriber based on the filtering policy.
      Subscription filtering policies are configured in JSON. The following is an example.
      {
          "filter_polices": [
              {
                  "name": "policy_name",
                  "string_equals": [
                      "policy_value"
                  ]
              }
          ]
      }
  7. Click OK.

    The subscription you added is displayed in the subscription list.

    • To prevent malicious users from attacking subscription endpoints, SMN limits the number of confirmation messages that can be sent to an endpoint within a specified period. For details, see section "Traffic Control on Subscription Confirmation" in Simple Message Notification User Guide.
    • SMN does not check whether subscription endpoints exist when you add subscriptions. However, subscribers will not receive notification messages until they confirm their subscriptions.
    • After you add a subscription, SMN sends a confirmation message to your subscription endpoint. You can confirm the subscription within 48 hours through the confirmation link via your mobile phone, mailbox, or other endpoints.
    • Subscription confirmation messages will be counted as messages sent and will be billed.