ALIYUN::MNS::Topic

Updated at:

ALIYUN::MNS::Topic is used to create a topic.

Syntax

{
  "Type": "ALIYUN::MNS::Topic",
  "Properties": {
    "LoggingEnabled": Boolean,
    "TopicName": String,
    "MaximumMessageSize": Integer,
    "Tags": List
  }
}

Properties

Property

Type

Required

Editable

Description

Constraints

TopicName

String

Yes

No

The name of the topic.

The topic name must be unique within the same account and region.

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

LoggingEnabled

Boolean

No

Yes

Specifies whether to enable the log management feature.

Default value: false. Valid values:

  • true: enables the log management feature.

  • false: disables the log management feature.

MaximumMessageSize

Integer

No

Yes

The maximum size of the message body sent to the topic.

Valid values: 1024 (1 KB) to 65536 (64 KB).

Unit: bytes.

Default value: 65536 (64 KB).

Tags

List

No

No

The tags of the topic.

For more information, see Tags properties.

Tags syntax

"Tags": [{
  "Key": String,
  "Value": String
}]

Tags properties

Property

Type

Required

Editable

Description

Constraints

Key

String

Yes

No

The tag key.

None.

Value

String

No

No

The tag value.

None.

Return values

Fn::GetAtt

  • TopicUrl: The URL of the created topic.

  • TopicName: The name of the created topic.

  • ARN.WithSlash: The ARN of the created topic.

Examples

Scenario 1: Create an MNS topic

# Scenario 1: Create a simple MNS topic
# Create a simple MNS topic with default configurations
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a simple MNS topic with default configurations.
  en: Create a simple MNS topic with default configuration.
Parameters:
  TopicName:
    Type: String
    Label:
      zh-cn: Topic name
      en: Topic Name
    Description:
      zh-cn: The topic name. It must be unique within the same account and region.
      en: The topic name. Must be unique in the same account and region.
    Default: my-first-topic
    MinLength: 1
    MaxLength: 256
Resources:
  Topic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Ref: TopicName
Outputs:
  TopicName:
    Description:
      zh-cn: Topic name.
      en: Topic name.
    Label:
      zh-cn: Topic name
      en: Topic Name
    Value:
      Fn::GetAtt:
        - Topic
        - TopicName
  TopicUrl:
    Description:
      zh-cn: The URL of the topic.
      en: The URL of the topic.
    Label:
      zh-cn: Topic URL
      en: Topic URL
    Value:
      Fn::GetAtt:
        - Topic
        - TopicUrl
Metadata:
  ALIYUN::ROS::Interface:
    ParameterGroups:
      - Parameters:
          - TopicName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a simple MNS topic with default configurations.",
    "en": "Create a simple MNS topic with default configuration."
  },
  "Parameters": {
    "TopicName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Topic name",
        "en": "Topic Name"
      },
      "Description": {
        "zh-cn": "The topic name. It must be unique within the same account and region.",
        "en": "The topic name. Must be unique in the same account and region."
      },
      "Default": "my-first-topic",
      "MinLength": 1,
      "MaxLength": 256
    }
  },
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Ref": "TopicName"
        }
      }
    }
  },
  "Outputs": {
    "TopicName": {
      "Description": {
        "zh-cn": "Topic name.",
        "en": "Topic name."
      },
      "Label": {
        "zh-cn": "Topic name",
        "en": "Topic Name"
      },
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "TopicName"
        ]
      }
    },
    "TopicUrl": {
      "Description": {
        "zh-cn": "The URL of the topic.",
        "en": "The URL of the topic."
      },
      "Label": {
        "zh-cn": "Topic URL",
        "en": "Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "TopicUrl"
        ]
      }
    }
  },
  "Metadata": {
    "ALIYUN::ROS::Interface": {
      "ParameterGroups": [
        {
          "Parameters": [
            "TopicName"
          ]
        }
      ]
    }
  }
}

Scenario 2: Create an MNS topic, a subscriber queue, and a subscription for message publish/subscribe

# Scenario 2: Create an MNS topic, a subscriber queue, and a subscription for message publish/subscribe
# Create an MNS topic, a subscriber queue and a subscription for message publish/subscribe
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create an MNS topic and a subscriber queue, and create a subscription from the topic to the queue to push messages from the topic to the queue.
  en: Create an MNS topic and a subscriber queue, then create a subscription from the topic to the queue for message push.
Parameters:
  CommonName:
    Type: String
    Label:
      zh-cn: Resource name prefix
      en: Resource Name Prefix
    Description:
      zh-cn: The unified name prefix for all resources.
      en: Unified name prefix for all resources.
    Default: pubsub-demo
  LoggingEnabled:
    Type: Boolean
    Label:
      zh-cn: Enable logging
      en: Enable Logging
    Description:
      zh-cn: Specifies whether to enable Log Management for the topic and queue.
      en: Whether to enable log management for the topic and queue.
    Default: true
Resources:
  Topic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-topic
      MaximumMessageSize: 65536
      LoggingEnabled:
        Ref: LoggingEnabled
      Tags:
        - Key: CreatedBy
          Value: ROS
  SubscriberQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-queue
      MessageRetentionPeriod: 345600
      VisibilityTimeout: 30
      PollingWaitSeconds: 10
      LoggingEnabled:
        Ref: LoggingEnabled
      Tags:
        - Key: CreatedBy
          Value: ROS
  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
      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
  TopicUrl:
    Description:
      zh-cn: The URL of the topic.
      en: The URL of the topic.
    Label:
      zh-cn: Topic URL
      en: Topic URL
    Value:
      Fn::GetAtt:
        - Topic
        - TopicUrl
  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
          - LoggingEnabled
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create an MNS topic and a subscriber queue, and create a subscription from the topic to the queue to push messages from the topic to the queue.",
    "en": "Create an MNS topic and a subscriber queue, then create a subscription from the topic to the queue for message push."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Resource name prefix",
        "en": "Resource Name Prefix"
      },
      "Description": {
        "zh-cn": "The unified name prefix for all resources.",
        "en": "Unified name prefix for all resources."
      },
      "Default": "pubsub-demo"
    },
    "LoggingEnabled": {
      "Type": "Boolean",
      "Label": {
        "zh-cn": "Enable logging",
        "en": "Enable Logging"
      },
      "Description": {
        "zh-cn": "Specifies whether to enable Log Management for the topic and queue.",
        "en": "Whether to enable log management for the topic and queue."
      },
      "Default": true
    }
  },
  "Resources": {
    "Topic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-topic"
        },
        "MaximumMessageSize": 65536,
        "LoggingEnabled": {
          "Ref": "LoggingEnabled"
        },
        "Tags": [
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "SubscriberQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-queue"
        },
        "MessageRetentionPeriod": 345600,
        "VisibilityTimeout": 30,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": {
          "Ref": "LoggingEnabled"
        },
        "Tags": [
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "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"
                ]
              }
            }
          ]
        },
        "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"
        ]
      }
    },
    "TopicUrl": {
      "Description": {
        "zh-cn": "The URL of the topic.",
        "en": "The URL of the topic."
      },
      "Label": {
        "zh-cn": "Topic URL",
        "en": "Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "Topic",
          "TopicUrl"
        ]
      }
    },
    "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",
            "LoggingEnabled"
          ]
        }
      ]
    }
  }
}

Scenario 3: Create a multi-topic, multi-subscription event-driven architecture that groups topics by business domain and uses FilterTag for refined message routing

# Scenario 3: Create a multi-topic, multi-subscription event-driven architecture that groups topics by business domain and uses FilterTag for refined message routing
# Create a multi-topic multi-subscription event-driven architecture with business-domain topics and FilterTag-based message routing
ROSTemplateFormatVersion: '2015-09-01'
Description:
  zh-cn: Create a complete event-driven architecture that includes multiple MNS topics by business domain (order, inventory, and notification), multiple subscription queues filtered by message tag under each topic, and a unified dead letter queue to implement refined routing and failure fallback for e-commerce events.
  en: Create a complete event-driven architecture including multiple business-domain MNS topics (order, inventory, notification), multiple subscription queues filtered by message tags under each topic, and a unified dead letter queue for refined routing of e-commerce events with failure fallback.
Parameters:
  CommonName:
    Type: String
    Label:
      zh-cn: Resource name prefix
      en: Resource Name Prefix
    Description:
      zh-cn: The unified name prefix for all resources.
      en: Unified name prefix for all resources.
    Default: event-center
  MaxReceiveCount:
    Type: Number
    Label:
      zh-cn: Maximum receive count
      en: Max Receive Count
    Description:
      zh-cn: The maximum number of times that a message can be consumed. When exceeded, the message 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:
  OrderTopic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-order-topic
      MaximumMessageSize: 65536
      LoggingEnabled: true
      Tags:
        - Key: Domain
          Value: Order
        - Key: CreatedBy
          Value: ROS
  InventoryTopic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-inventory-topic
      MaximumMessageSize: 65536
      LoggingEnabled: true
      Tags:
        - Key: Domain
          Value: Inventory
        - Key: CreatedBy
          Value: ROS
  NotificationTopic:
    Type: ALIYUN::MNS::Topic
    Properties:
      TopicName:
        Fn::Sub: ${CommonName}-notification-topic
      MaximumMessageSize: 65536
      LoggingEnabled: true
      Tags:
        - Key: Domain
          Value: Notification
        - Key: CreatedBy
          Value: ROS
  DeadLetterQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-dlq
      MessageRetentionPeriod: 604800
      LoggingEnabled: true
      Tags:
        - Key: QueueType
          Value: DeadLetter
  OrderCreatedQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-order-created-queue
      VisibilityTimeout: 60
      PollingWaitSeconds: 10
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
  OrderPaidQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-order-paid-queue
      VisibilityTimeout: 60
      PollingWaitSeconds: 10
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
  StockWarningQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-stock-warning-queue
      VisibilityTimeout: 30
      PollingWaitSeconds: 10
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
  SmsNotifyQueue:
    Type: ALIYUN::MNS::Queue
    Properties:
      QueueName:
        Fn::Sub: ${CommonName}-sms-notify-queue
      VisibilityTimeout: 30
      PollingWaitSeconds: 10
      LoggingEnabled: true
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
        MaxReceiveCount:
          Ref: MaxReceiveCount
  OrderCreatedSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - OrderTopic
      - OrderCreatedQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - OrderTopic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-order-created-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - OrderCreatedQueue
                - QueueName
      FilterTag: created
      NotifyContentFormat: JSON
      NotifyStrategy: EXPONENTIAL_DECAY_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
  OrderPaidSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - OrderTopic
      - OrderPaidQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - OrderTopic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-order-paid-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - OrderPaidQueue
                - QueueName
      FilterTag: paid
      NotifyContentFormat: JSON
      NotifyStrategy: EXPONENTIAL_DECAY_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
  StockWarningSubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - InventoryTopic
      - StockWarningQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - InventoryTopic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-stock-warning-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - StockWarningQueue
                - QueueName
      FilterTag: warning
      NotifyContentFormat: JSON
      NotifyStrategy: BACKOFF_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
  SmsNotifySubscription:
    Type: ALIYUN::MNS::Subscription
    DependsOn:
      - NotificationTopic
      - SmsNotifyQueue
    Properties:
      TopicName:
        Fn::GetAtt:
          - NotificationTopic
          - TopicName
      SubscriptionName:
        Fn::Sub: ${CommonName}-sms-notify-sub
      PushType: queue
      Endpoint:
        Fn::Sub:
          - acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}
          - QueueName:
              Fn::GetAtt:
                - SmsNotifyQueue
                - QueueName
      FilterTag: sms
      NotifyContentFormat: JSON
      NotifyStrategy: BACKOFF_RETRY
      DlqPolicy:
        Enabled: true
        DeadLetterTargetQueue:
          Fn::Sub: ${CommonName}-dlq
Outputs:
  OrderTopicUrl:
    Description:
      zh-cn: Order topic URL.
      en: Order topic URL.
    Label:
      zh-cn: Order topic URL
      en: Order Topic URL
    Value:
      Fn::GetAtt:
        - OrderTopic
        - TopicUrl
  InventoryTopicUrl:
    Description:
      zh-cn: Inventory topic URL.
      en: Inventory topic URL.
    Label:
      zh-cn: Inventory topic URL
      en: Inventory Topic URL
    Value:
      Fn::GetAtt:
        - InventoryTopic
        - TopicUrl
  NotificationTopicUrl:
    Description:
      zh-cn: Notification topic URL.
      en: Notification topic URL.
    Label:
      zh-cn: Notification topic URL
      en: Notification Topic URL
    Value:
      Fn::GetAtt:
        - NotificationTopic
        - TopicUrl
  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
          - MaxReceiveCount
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Description": {
    "zh-cn": "Create a complete event-driven architecture that includes multiple MNS topics by business domain (order, inventory, and notification), multiple subscription queues filtered by message tag under each topic, and a unified dead letter queue to implement refined routing and failure fallback for e-commerce events.",
    "en": "Create a complete event-driven architecture including multiple business-domain MNS topics (order, inventory, notification), multiple subscription queues filtered by message tags under each topic, and a unified dead letter queue for refined routing of e-commerce events with failure fallback."
  },
  "Parameters": {
    "CommonName": {
      "Type": "String",
      "Label": {
        "zh-cn": "Resource name prefix",
        "en": "Resource Name Prefix"
      },
      "Description": {
        "zh-cn": "The unified name prefix for all resources.",
        "en": "Unified name prefix for all resources."
      },
      "Default": "event-center"
    },
    "MaxReceiveCount": {
      "Type": "Number",
      "Label": {
        "zh-cn": "Maximum receive count",
        "en": "Max Receive Count"
      },
      "Description": {
        "zh-cn": "The maximum number of times that a message can be consumed. When exceeded, the message 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": {
    "OrderTopic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-order-topic"
        },
        "MaximumMessageSize": 65536,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "Domain",
            "Value": "Order"
          },
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "InventoryTopic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-inventory-topic"
        },
        "MaximumMessageSize": 65536,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "Domain",
            "Value": "Inventory"
          },
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "NotificationTopic": {
      "Type": "ALIYUN::MNS::Topic",
      "Properties": {
        "TopicName": {
          "Fn::Sub": "${CommonName}-notification-topic"
        },
        "MaximumMessageSize": 65536,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "Domain",
            "Value": "Notification"
          },
          {
            "Key": "CreatedBy",
            "Value": "ROS"
          }
        ]
      }
    },
    "DeadLetterQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-dlq"
        },
        "MessageRetentionPeriod": 604800,
        "LoggingEnabled": true,
        "Tags": [
          {
            "Key": "QueueType",
            "Value": "DeadLetter"
          }
        ]
      }
    },
    "OrderCreatedQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-order-created-queue"
        },
        "VisibilityTimeout": 60,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        }
      }
    },
    "OrderPaidQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-order-paid-queue"
        },
        "VisibilityTimeout": 60,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        }
      }
    },
    "StockWarningQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-stock-warning-queue"
        },
        "VisibilityTimeout": 30,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        }
      }
    },
    "SmsNotifyQueue": {
      "Type": "ALIYUN::MNS::Queue",
      "Properties": {
        "QueueName": {
          "Fn::Sub": "${CommonName}-sms-notify-queue"
        },
        "VisibilityTimeout": 30,
        "PollingWaitSeconds": 10,
        "LoggingEnabled": true,
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          },
          "MaxReceiveCount": {
            "Ref": "MaxReceiveCount"
          }
        }
      }
    },
    "OrderCreatedSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "OrderTopic",
        "OrderCreatedQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "OrderTopic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-order-created-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "OrderCreatedQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "created",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "EXPONENTIAL_DECAY_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    },
    "OrderPaidSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "OrderTopic",
        "OrderPaidQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "OrderTopic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-order-paid-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "OrderPaidQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "paid",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "EXPONENTIAL_DECAY_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    },
    "StockWarningSubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "InventoryTopic",
        "StockWarningQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "InventoryTopic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-stock-warning-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "StockWarningQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "warning",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "BACKOFF_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    },
    "SmsNotifySubscription": {
      "Type": "ALIYUN::MNS::Subscription",
      "DependsOn": [
        "NotificationTopic",
        "SmsNotifyQueue"
      ],
      "Properties": {
        "TopicName": {
          "Fn::GetAtt": [
            "NotificationTopic",
            "TopicName"
          ]
        },
        "SubscriptionName": {
          "Fn::Sub": "${CommonName}-sms-notify-sub"
        },
        "PushType": "queue",
        "Endpoint": {
          "Fn::Sub": [
            "acs:mns:${ALIYUN::Region}:${ALIYUN::TenantId}:queues/${QueueName}",
            {
              "QueueName": {
                "Fn::GetAtt": [
                  "SmsNotifyQueue",
                  "QueueName"
                ]
              }
            }
          ]
        },
        "FilterTag": "sms",
        "NotifyContentFormat": "JSON",
        "NotifyStrategy": "BACKOFF_RETRY",
        "DlqPolicy": {
          "Enabled": true,
          "DeadLetterTargetQueue": {
            "Fn::Sub": "${CommonName}-dlq"
          }
        }
      }
    }
  },
  "Outputs": {
    "OrderTopicUrl": {
      "Description": {
        "zh-cn": "Order topic URL.",
        "en": "Order topic URL."
      },
      "Label": {
        "zh-cn": "Order topic URL",
        "en": "Order Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "OrderTopic",
          "TopicUrl"
        ]
      }
    },
    "InventoryTopicUrl": {
      "Description": {
        "zh-cn": "Inventory topic URL.",
        "en": "Inventory topic URL."
      },
      "Label": {
        "zh-cn": "Inventory topic URL",
        "en": "Inventory Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "InventoryTopic",
          "TopicUrl"
        ]
      }
    },
    "NotificationTopicUrl": {
      "Description": {
        "zh-cn": "Notification topic URL.",
        "en": "Notification topic URL."
      },
      "Label": {
        "zh-cn": "Notification topic URL",
        "en": "Notification Topic URL"
      },
      "Value": {
        "Fn::GetAtt": [
          "NotificationTopic",
          "TopicUrl"
        ]
      }
    },
    "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",
            "MaxReceiveCount"
          ]
        }
      ]
    }
  }
}