ALIYUN::MNS::Subscription

Updated at:

The ALIYUN::MNS::Subscription resource type is used to describe a subscription relationship, including the subscribed topic and the endpoint that receives messages.

Syntax

{
  "Type": "ALIYUN::MNS::Subscription",
  "Properties": {
    "Endpoint": String,
    "NotifyStrategy": String,
    "FilterTag": String,
    "NotifyContentFormat": String,
    "SubscriptionName": String,
    "TopicName": String,
    "DlqPolicy": Map,
    "PushType": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraints

Endpoint

String

Yes

No

The endpoint that receives messages for this subscription.

Valid values:

  • HttpEndpoint: Must be prefixed with http://.

  • QueueEndpoint: Must be in the format acs:mns:{REGION}:{AccountID}:queues/{QueueName}.

  • MailEndpoint: Must be in the format mail:directmail:{MailAddress}.

  • SmsEndpoint: Must be sms:directsms:anonymous or sms:directsms:{Phone}.

SubscriptionName

String

Yes

No

The subscription name.

Can contain up to 256 characters. Must start with a letter and can contain letters, digits, and hyphens (-).

TopicName

String

Yes

No

The topic name.

The topic name must be unique within an Alibaba Cloud account in a region. Can contain up to 256 characters. Must start with a letter and can contain letters, digits, and hyphens (-).

DlqPolicy

Map

No

Yes

Dead-letter policy.

For more information, see DlqPolicy properties.

FilterTag

String

No

No

The tag used to filter messages in this subscription.

Can contain up to 16 characters. By default, messages are not filtered.

Note

Only messages with matching tags are pushed.

NotifyContentFormat

String

No

No

The format of messages pushed to the Endpoint.

Valid values:

  • XML (default)

  • JSON

  • SIMPLIFIED

For more information about message formats, see NotifyContentFormat.

NotifyStrategy

String

No

Yes

The retry policy used when an error occurs while pushing messages to the Endpoint.

Valid values:

  • BACKOFF_RETRY (default)

  • EXPONENTIAL_DECAY_RETRY

For more information about retry policies, see NotifyStrategy.

PushType

String

No

No

The endpoint type.

Valid values:

  • http: HTTP push type.

  • queue: queue push type.

  • mpush: mobile push type.

  • alisms: Alibaba Cloud Short Message Service (SMS) push type.

  • email: email push type.

DlqPolicy syntax

"DlqPolicy": {
  "DeadLetterTargetQueue": String,
  "Enabled": Boolean
}

DlqPolicy properties

Property

Type

Required

Editable

Description

Constraints

DeadLetterTargetQueue

String

Yes

Yes

The target queue to which dead-letter messages are delivered.

None.

Enabled

Boolean

Yes

Yes

Specifies whether to enable dead-letter message delivery.

None.

Return values

Fn::GetAtt

  • SubscriptionUrl: The URL of the created subscription.

  • SubscriptionName: The subscription name.

  • TopicName: The topic name.

Examples

Scenario 1: Create a simple HTTP subscription for an existing topic

# Scenario 1: Create a simple HTTP subscription for an existing topic
# Create a simple HTTP subscription for an existing topic
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a simple HTTP push subscription for an existing MNS topic to push messages to a specified HTTP callback URL.
  en: Create a simple HTTP push subscription for an existing MNS topic to push messages to a specified HTTP callback URL.
Parameters:
  TopicName:
    Type: String
    Label:
      zh-cn: Topic Name
      en: Topic Name
    Description:
      zh-cn: The name of an existing MNS topic.
      en: The name of an existing MNS topic.
  SubscriptionName:
    Type: String
    Label:
      zh-cn: Subscription Name
      en: Subscription Name
    Description:
      zh-cn: The name of the subscription.
      en: The name of the subscription.
    Default: my-http-subscription
  HttpEndpoint:
    Type: String
    Label:
      zh-cn: HTTP Callback URL
      en: HTTP Callback URL
    Description:
      zh-cn: The HTTP/HTTPS callback URL to receive message push, e.g. http://example.com/callback.
      en: The HTTP/HTTPS callback URL to receive message push, e.g. http://example.com/callback.
Resources:
  Subscription:
    Type: ALIYUN::MNS::Subscription
    Properties:
      TopicName:
        Ref: TopicName
      SubscriptionName:
        Ref: SubscriptionName
      PushType: http
      Endpoint:
        Ref: HttpEndpoint
Outputs:
  SubscriptionName:
    Description:
      zh-cn: Subscription name.
      en: Subscription name.
    Label:
      zh-cn: Subscription Name
      en: Subscription Name
    Value:
      Fn::GetAtt:
        - Subscription
        - SubscriptionName
  SubscriptionUrl:
    Description:
      zh-cn: The URL of the subscription.
      en: The URL of the subscription.
    Label:
      zh-cn: Subscription URL
      en: Subscription URL
    Value:
      Fn::GetAtt:
        - Subscription
        - SubscriptionUrl
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - TopicName
          - SubscriptionName
          - HttpEndpoint
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a simple HTTP push subscription for an existing MNS topic to push messages to a specified HTTP callback URL.",
    "en": "Create a simple HTTP push subscription for an existing MNS topic to push messages to a specified HTTP callback URL."
  },
  "Parameters": {
    "TopicName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Topic Name",
        "en": "Topic Name"
      },
      "Description": {
        "zh-cn": "The name of an existing MNS topic.",
        "en": "The name of an existing MNS topic."
      }
    },
    "SubscriptionName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Subscription Name",
        "en": "Subscription Name"
      },
      "Description": {
        "zh-cn": "The name of the subscription.",
        "en": "The name of the subscription."
      },
      "Default": "my-http-subscription"
    },
    "HttpEndpoint": {
      "Type": "String",
      "Label": {
        "zh-cn": "HTTP Callback URL",
        "en": "HTTP Callback URL"
      },
      "Description": {
        "zh-cn": "The HTTP/HTTPS callback URL to receive message push, e.g. http://example.com/callback.",
        "en": "The HTTP/HTTPS callback URL to receive message push, e.g. http://example.com/callback."
      }
    }
  },
  "Resources": {
    "Subscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "Properties": {
        "TopicName": {
          "Ref": "TopicName"
        },
        "SubscriptionName": {
          "Ref": "SubscriptionName"
        },
        "PushType": "http",
        "Endpoint": {
          "Ref": "HttpEndpoint"
        }
      }
    }
  },
  "Outputs": {
    "SubscriptionName": {
      "Description": {
        "zh-cn": "Subscription name.",
        "en": "Subscription name."
      },
      "Label": {
        "zh-cn": "Subscription Name",
        "en": "Subscription Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "Subscription",
          "SubscriptionName"
        ]
      }
    },
    "SubscriptionUrl": {
      "Description": {
        "zh-cn": "The URL of the subscription.",
        "en": "The URL of the subscription."
      },
      "Label": {
        "zh-cn": "Subscription URL",
        "en": "Subscription URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "Subscription",
          "SubscriptionUrl"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "TopicName",
            "SubscriptionName",
            "HttpEndpoint"
          ]
        }
      ]
    }
  }
}

Scenario 2: Create a topic and a queue, and create a queue-push subscription with message tag filtering

# Scenario 2: Create a topic and a queue, and create a queue-push subscription with message tag filtering
# Create a topic and a queue, then create a queue-push subscription with message tag filtering
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create an MNS topic and a subscriber queue, create a queue-push subscription with FilterTag-based message filtering so that only messages with matching tags are pushed to the queue.
  en: Create an MNS topic and a subscriber queue, create a queue-push subscription with FilterTag-based message filtering so that only messages with matching tags are pushed to the queue.
Parameters:
  CommonName:
    Type: String
    Label:
      zh-cn: Resource Name Prefix
      en: Resource Name Prefix
    Description:
      zh-cn: Unified name prefix for all resources.
      en: Unified name prefix for all resources.
    Default: filtered-sub
  FilterTag:
    Type: String
    Label:
      zh-cn: Message Filter Tag
      en: Message Filter Tag
    Description:
      zh-cn: The message filter tag, up to 16 characters. Only messages with matching tags are pushed.
      en: The message filter tag, up to 16 characters. Only messages with matching tags are pushed.
    Default: important
    MaxLength: 16
Resources:
  Topic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-topic
      LoggingEnabled: true
  SubscriberQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-queue
      MessageRetentionPeriod: 345600
      VisibilityTimeout: 30
      PollingWaitSeconds: 10
      LoggingEnabled: true
  Subscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - Topic
      - SubscriberQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - Topic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - SubscriberQueue
                - QueueName
      FilterTag:
        Ref: FilterTag
      NotifyContentFormat: JSON
      NotifyStrategy: BACKOFF_RETRY
Outputs:
  TopicName:
    Description:
      zh-cn: Topic name.
      en: Topic name.
    Label:
      zh-cn: Topic Name
      en: Topic Name
    Value:
      Fn::GetAtt:
        - Topic
        - TopicName
  QueueUrl:
    Description:
      zh-cn: The URL of the subscriber queue.
      en: The URL of the subscriber queue.
    Label:
      zh-cn: Queue URL
      en: Queue URL
    Value:
      Fn::GetAtt:
        - SubscriberQueue
        - QueueUrl
  SubscriptionUrl:
    Description:
      zh-cn: The URL of the subscription.
      en: The URL of the subscription.
    Label:
      zh-cn: Subscription URL
      en: Subscription URL
    Value:
      Fn::GetAtt:
        - Subscription
        - SubscriptionUrl
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - CommonName
          - FilterTag
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create an MNS topic and a subscriber queue, create a queue-push subscription with FilterTag-based message filtering so that only messages with matching tags are pushed to the queue.",
    "en": "Create an MNS topic and a subscriber queue, create a queue-push subscription with FilterTag-based message filtering so that only messages with matching tags are pushed to the queue."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Resource Name Prefix",
        "en": "Resource Name Prefix"
      },
      "Description": {
        "zh-cn": "Unified name prefix for all resources.",
        "en": "Unified name prefix for all resources."
      },
      "Default": "filtered-sub"
    },
    "FilterTag": {
      "Type": "String",
      "Label": {
        "zh-cn": "Message Filter Tag",
        "en": "Message Filter Tag"
      },
      "Description": {
        "zh-cn": "The message filter tag, up to 16 characters. Only messages with matching tags are pushed.",
        "en": "The message filter tag, up to 16 characters. Only messages with matching tags are pushed."
      },
      "Default": "important",
      "MaxLength": 16
    }
  },
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-topic"
        },
        "LoggingEnabled": true
      }
    },
    "SubscriberQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-queue"
        },
        "MessageRetentionPeriod": 345600,
        "VisibilityTimeout": 30,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": true
      }
    },
    "Subscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "Topic",
        "SubscriberQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "Topic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "SubscriberQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": {
          "Ref": "FilterTag"
        },
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "BACKOFF_RETRY"
      }
    }
  },
  "Outputs": {
    "TopicName": {
      "Description": {
        "zh-cn": "Topic name.",
        "en": "Topic name."
      },
      "Label": {
        "zh-cn": "Topic Name",
        "en": "Topic Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "TopicName"
        ]
      }
    },
    "QueueUrl": {
      "Description": {
        "zh-cn": "The URL of the subscriber queue.",
        "en": "The URL of the subscriber queue."
      },
      "Label": {
        "zh-cn": "Queue URL",
        "en": "Queue URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "SubscriberQueue",
          "QueueUrl"
        ]
      }
    },
    "SubscriptionUrl": {
      "Description": {
        "zh-cn": "The URL of the subscription.",
        "en": "The URL of the subscription."
      },
      "Label": {
        "zh-cn": "Subscription URL",
        "en": "Subscription URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "Subscription",
          "SubscriptionUrl"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "CommonName",
            "FilterTag"
          ]
        }
      ]
    }
  }
}

Scenario 3: Create queue and HTTP subscriptions for a topic with dead-letter and retry policies

# Scenario 3: Create subscriptions with multiple push types (queue and HTTP) for a topic, and configure dead-letter and retry policies to provide multichannel message delivery and failure fallback
# Create multiple push-type subscriptions (queue + HTTP) for a topic with DLQ and retry policies for multi-channel message delivery with failure fallback
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create an MNS topic with a complete multi-channel subscription system including two queue subscriptions filtered by business tags with different retry strategies and one HTTP subscription pushing to a business callback, all with DLQ policies so failed messages go to a unified dead letter queue for reliable multi-channel delivery.
  en: Create an MNS topic with a complete multi-channel subscription system including two queue subscriptions filtered by business tags with different retry strategies and one HTTP subscription pushing to a business callback, all with DLQ policies so failed messages go to a unified dead letter queue for reliable multi-channel delivery.
Parameters:
  CommonName:
    Type: String
    Label:
      zh-cn: Resource Name Prefix
      en: Resource Name Prefix
    Description:
      zh-cn: Unified name prefix for all resources.
      en: Unified name prefix for all resources.
    Default: multi-channel
  HttpCallbackEndpoint:
    Type: String
    Label:
      zh-cn: HTTP Callback URL
      en: HTTP Callback URL
    Description:
      zh-cn: The HTTP/HTTPS callback URL to receive message push.
      en: The HTTP/HTTPS callback URL to receive message push.
    Default: http://example.com/mns/callback
  MaxReceiveCount:
    Type: Number
    Label:
      zh-cn: Max Receive Count
      en: Max Receive Count
    Description:
      zh-cn: The maximum number of times that a message can be received before it is delivered to the dead-letter queue.
      en: The maximum number of times a message can be received before being moved to the dead letter queue.
    Default: 3
    MinValue: 1
Resources:
  Topic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-topic
      MaximumMessageSize: 65536
      LoggingEnabled: true
      Tags:
        - Key: Architecture
          Value: MultiChannel
        - Key: CreatedBy
          Value: ROS
  DeadLetterQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-dlq
      MessageRetentionPeriod: 604800
      LoggingEnabled: true
      Tags:
        - Key: QueueType
          Value: DeadLetter
  UrgentQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-urgent-queue
      VisibilityTimeout: 30
      PollingWaitSeconds: 5
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
      Tags:
        - Key: Channel
          Value: Urgent
  NormalQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-normal-queue
      VisibilityTimeout: 60
      PollingWaitSeconds: 15
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
      Tags:
        - Key: Channel
          Value: Normal
  UrgentSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - Topic
      - UrgentQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - Topic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-urgent-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - UrgentQueue
                - QueueName
      FilterTag: urgent
      NotifyContentFormat: JSON
      NotifyStrategy: EXPONENTIAL_DECAY_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
  NormalSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - Topic
      - NormalQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - Topic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-normal-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - NormalQueue
                - QueueName
      FilterTag: normal
      NotifyContentFormat: JSON
      NotifyStrategy: BACKOFF_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
  HttpSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn: Topic
    Properties:
      TopicName:
        Fn::GetAtt:
          - Topic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-http-sub
      PushType: http
      Endpoint:
        Ref: HttpCallbackEndpoint
      NotifyContentFormat: JSON
      NotifyStrategy: EXPONENTIAL_DECAY_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
Outputs:
  TopicUrl:
    Description:
      zh-cn: Topic URL.
      en: Topic URL.
    Label:
      zh-cn: Topic URL
      en: Topic URL
    Value:
      Fn::GetAtt:
        - Topic
        - TopicUrl
  UrgentQueueUrl:
    Description:
      zh-cn: Urgent message queue URL.
      en: Urgent message queue URL.
    Label:
      zh-cn: Urgent Queue URL
      en: Urgent Queue URL
    Value:
      Fn::GetAtt:
        - UrgentQueue
        - QueueUrl
  NormalQueueUrl:
    Description:
      zh-cn: Normal message queue URL.
      en: Normal message queue URL.
    Label:
      zh-cn: Normal Queue URL
      en: Normal Queue URL
    Value:
      Fn::GetAtt:
        - NormalQueue
        - QueueUrl
  HttpSubscriptionUrl:
    Description:
      zh-cn: HTTP subscription URL.
      en: HTTP subscription URL.
    Label:
      zh-cn: HTTP Subscription URL
      en: HTTP Subscription URL
    Value:
      Fn::GetAtt:
        - HttpSubscription
        - SubscriptionUrl
  DeadLetterQueueUrl:
    Description:
      zh-cn: Dead-letter queue URL.
      en: Dead letter queue URL.
    Label:
      zh-cn: DLQ URL
      en: DLQ URL
    Value:
      Fn::GetAtt:
        - DeadLetterQueue
        - QueueUrl
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - CommonName
          - HttpCallbackEndpoint
          - MaxReceiveCount
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create an MNS topic and a complete multichannel subscription system, including two queue subscriptions filtered by business tags with different retry policies and one HTTP subscription that pushes messages to a business callback. Configure dead-letter policies for all subscriptions so failed messages are delivered to a dead-letter queue, enabling reliable multichannel message delivery.",
    "en": "Create an MNS topic with a complete multi-channel subscription system including two queue subscriptions filtered by business tags with different retry strategies and one HTTP subscription pushing to a business callback, all with DLQ policies so failed messages go to a unified dead letter queue for reliable multi-channel delivery."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Resource Name Prefix",
        "en": "Resource Name Prefix"
      },
      "Description": {
        "zh-cn": "Unified name prefix for all resources.",
        "en": "Unified name prefix for all resources."
      },
      "Default": "multi-channel"
    },
    "HttpCallbackEndpoint": {
      "Type": "String",
      "Label": {
        "zh-cn": "HTTP Callback URL",
        "en": "HTTP Callback URL"
      },
      "Description": {
        "zh-cn": "The HTTP/HTTPS callback URL to receive message push.",
        "en": "The HTTP/HTTPS callback URL to receive message push."
      },
      "Default": "http://example.com/mns/callback"
    },
    "MaxReceiveCount": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Max Receive Count",
        "en": "Max Receive Count"
      },
      "Description": {
        "zh-cn": "The maximum number of times a message can be received before being moved to the dead letter queue.",
        "en": "The maximum number of times a message can be received before being moved to the dead letter queue."
      },
      "Default": 3,
      "MinValue": 1
    }
  },
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-topic"
        },
        "MaximumMessageSize": 65536,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "Architecture",
            "Value": "MultiChannel"
          },
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "DeadLetterQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-dlq"
        },
        "MessageRetentionPeriod": 604800,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "QueueType",
            "Value": "DeadLetter"
          }
        ]
      }
    },
    "UrgentQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-urgent-queue"
        },
        "VisibilityTimeout": 30,
        "PollingWaitSeconds": 5,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        },
        "Tags": [
          {
            "Key": "Channel",
            "Value": "Urgent"
          }
        ]
      }
    },
    "NormalQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-normal-queue"
        },
        "VisibilityTimeout": 60,
        "PollingWaitSeconds": 15,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        },
        "Tags": [
          {
            "Key": "Channel",
            "Value": "Normal"
          }
        ]
      }
    },
    "UrgentSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "Topic",
        "UrgentQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "Topic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-urgent-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "UrgentQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "urgent",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "EXPONENTIAL_DECAY_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    },
    "NormalSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "Topic",
        "NormalQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "Topic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-normal-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "NormalQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "normal",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "BACKOFF_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    },
    "HttpSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": "Topic",
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "Topic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-http-sub"
        },
        "PushType": "http",
        "Endpoint": {
          "Ref": "HttpCallbackEndpoint"
        },
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "EXPONENTIAL_DECAY_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    }
  },
  "Outputs": {
    "TopicUrl": {
      "Description": {
        "zh-cn": "Topic URL.",
        "en": "Topic URL."
      },
      "Label": {
        "zh-cn": "Topic URL",
        "en": "Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "TopicUrl"
        ]
      }
    },
    "UrgentQueueUrl": {
      "Description": {
        "zh-cn": "Urgent message queue URL.",
        "en": "Urgent message queue URL."
      },
      "Label": {
        "zh-cn": "Urgent Queue URL",
        "en": "Urgent Queue URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "UrgentQueue",
          "QueueUrl"
        ]
      }
    },
    "NormalQueueUrl": {
      "Description": {
        "zh-cn": "Normal message queue URL.",
        "en": "Normal message queue URL."
      },
      "Label": {
        "zh-cn": "Normal Queue URL",
        "en": "Normal Queue URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "NormalQueue",
          "QueueUrl"
        ]
      }
    },
    "HttpSubscriptionUrl": {
      "Description": {
        "zh-cn": "HTTP subscription URL.",
        "en": "HTTP subscription URL."
      },
      "Label": {
        "zh-cn": "HTTP Subscription URL",
        "en": "HTTP Subscription URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "HttpSubscription",
          "SubscriptionUrl"
        ]
      }
    },
    "DeadLetterQueueUrl": {
      "Description": {
        "zh-cn": "Dead-letter queue URL.",
        "en": "Dead letter queue URL."
      },
      "Label": {
        "zh-cn": "DLQ URL",
        "en": "DLQ URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "DeadLetterQueue",
          "QueueUrl"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "CommonName",
            "HttpCallbackEndpoint",
            "MaxReceiveCount"
          ]
        }
      ]
    }
  }
}