All Products
Search
Document Center

Simple Message Queue (formerly MNS):Subscription

Last Updated:Dec 20, 2024

This topic describes the definition of a subscription, its relationship with other components, and its internal attributes in Simple Message Queue (formerly MNS).

Definition and relationship with other components

In Simple Message Queue (formerly MNS), a subscription is a rule based on which consumers register for a specific topic to receive messages. You can associate one or more subscriptions with a specific topic and customize the push rule and receiver for each subscription.

The following figure shows the relationship of a subscription with other components in a messaging model of Simple Message Queue (formerly MNS).

image

Feature description

  • Multiple subscription types: One topic can have multiple subscriptions, which correspond to different types of receivers.

  • Repeated message subscription: Each subscription can subscribe to all messages of a specific topic.

Subscription attributes

Subscription name

  • Definition: the name of a subscription, which uniquely identifies the subscription. A subscriber cannot create multiple subscriptions with the same name for the same topic.

  • Value: The name can be up to 255 characters in length and can contain letters, digits, and hyphens (-). It must start with a letter.

Subscription type

  • Definition: the type of an endpoint that subscribes to messages.

  • Value: The options are Queue, HTTP Server, Short Message Service, Mobile Push, and Direct Mail. For more information, see Subscription type.

Receiver endpoint (Endpoint)

  • Definition: the endpoint that receives messages.

  • Value:

    • If the subscription type is HTTP Server, the value is an HTTP URL that starts with http:// or https://.

    • If the subscription type is Queue, the value is a queue name.

    • If the subscription type is SMS, the value is a mobile number.

    • If the subscription type is Direct Mail, the value is an email address.

    • If the subscription type to Mobile Push, the value is an app key.

Message filtering tag

  • Definition: the tag used to filter messages. For more information about message filtering tags, see Message filtering.

  • Value: The tag can be up to 16 characters in length. Only one tag can be specified.

Retry policy (NotifyStrategy)

  • Definition: the policy that defines how SMQ retries message pushing in case of errors when SMQ pushes messages to a receiver. If a message fails to be pushed, Simple Message Queue (formerly MNS) retries to push the message based on the retry policy. After the maximum retries are reached, Simple Message Queue (formerly MNS) discards the message and continues to push the next message.

  • Value:

    • BACKOFF_RETRY: indicates three retries with a random delay between 10 seconds and 20 seconds for each retry.

    • EXPONENTIAL_DECAY_RETRY: indicates 176 retries with exponentially increasing delays, capped at 512 seconds. The total retry duration is one day. The specific retry intervals are 1 second, 2 seconds, 4 seconds, 8 seconds, 16 seconds, 32 seconds, 64 seconds, 128 seconds, 256 seconds, and then 512 seconds for the remaining 167 retries.

Message format (NotifyContentFormat)

  • Definition: the format of the messages to be pushed to receivers.

  • Value:

    • SIMPLIFIED: The message body contains the message content but no message attributes. Example:

      {1:"a", 2:"b"}
    • JSON: The message body contains the message content and the message attributes. Example:

      {
          "TopicOwner":"TopicOwner",
          "TopicName":"TopicName",
          "Subscriber":"Subscriber",
          "SubscriptionName":"SubscriptionName",
          "MessageId":"6CC4D900CA59A2CD-1-15180534A8F-20000****",
          "Message":"xxxxx",
          "MessageMD5":"F1E92841751D795AB325861034B5****",
          "MessageTag":"important",
          "PublishTime":"1449556920975"
      }
    • XML: The message body contains the message content and the message attributes. Example:

      <?xml version="1.0" encoding="utf-8"?>
          <Notification xlmns="http://mns.aliyuncs.com/doc/v1/">
              <TopicOwner>TopicOwner</TopicOwner>
              <TopicName>TopicName</TopicName>
              <Subscriber>Subscriber</Subscriber>
              <SubscriptionName>SubscriptionName</SubscriptionName>
              <MessageId>6CC4D900CA59A2CD-1-15180534A8F-20000****</MessageId>
              <Message>{1:"a", 2:"b"}</Message>
              <MessageMD5>F1E92841751D795AB325861034B5****</MessageMD5>
              <MessageTag>important</MessageTag>
              <PublishTime>1449556920975</MessagePublishTime>
          </Notification>
    Note

    If the subscription type is SMS or Direct Mail, the message format can only be SIMPLIFIED.