All Products
Search
Document Center

Resource Orchestration Service:ALIYUN::AMQP::Exchange

Last Updated:Jun 22, 2026

Creates an exchange in an ApsaraMQ for RabbitMQ instance.

Syntax

{
  "Type": "ALIYUN::AMQP::Exchange",
  "Properties": {
    "InstanceId": String,
    "AlternateExchange": String,
    "Internal": Boolean,
    "VirtualHost": String,
    "AutoDeleteState": Boolean,
    "ExchangeName": String,
    "ExchangeType": String,
    "XDelayedType": String
  }
}

Properties

Property

Type

Required

Editable

Description

Constraint

AutoDeleteState

Boolean

Yes

No

Specifies whether to automatically delete the exchange.

Valid values:

  • true: The exchange is automatically deleted when the last bound queue is unbound.

  • false: The exchange is not automatically deleted when the last bound queue is unbound.

ExchangeName

String

Yes

No

The exchange name.

  • The name of an exchange must be 1 to 255 characters in length and can contain only letters, digits, hyphens (-), underscores (_), periods (.), number signs (#), forward slashes (/), and at signs (@).

  • The exchange name cannot be modified after the exchange is created. To rename an exchange, delete it and create a new one.

ExchangeType

String

Yes

No

The exchange type.

Valid values:

  • DIRECT: Routes a message to the queue whose binding key exactly matches the routing key of the message.

  • TOPIC: Similar to a direct exchange, but routes a message to one or more queues based on fuzzy or multi-condition matching between the routing key and the binding keys.

  • FANOUT: Routes all received messages to all bound queues. Use this type to broadcast messages.

  • HEADERS: Similar to a direct exchange, but routes messages based on headers attributes instead of routing keys. Binding attributes and message headers are both specified as key-value pairs, and the exchange matches them to determine routing.

InstanceId

String

Yes

No

The instance ID.

None.

Internal

Boolean

Yes

No

Specifies whether the exchange is an internal exchange.

Valid values:

  • true

  • false

VirtualHost

String

Yes

No

The vhost in which to create the exchange.

None.

AlternateExchange

String

No

No

The alternate exchange.

An alternate exchange receives messages that cannot be routed to any queue from the current exchange.

XDelayedType

String

No

No

The exchange type for delayed message delivery.

Use the x-delay header to specify a delay in milliseconds before the message is delivered from an x-delayed-message exchange. The routing rule varies based on the exchange type specified by this property. Valid values:

  • DIRECT: delivers delayed messages to queues that are bound to a direct exchange.

  • TOPIC: delivers delayed messages to queues that are bound to a topic exchange.

  • FANOUT: delivers delayed messages to queues that are bound to a fanout exchange.

  • HEADERS: delivers delayed messages to queues that are bound to a headers exchange.

  • X-JMS-TOPIC: delivers delayed messages to queues that are bound to an x-jms-topic exchange.

Return values

Fn::GetAtt

ExchangeName: the exchange name.

Examples

YAML format

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  AutoDeleteState:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: 'Specifies whether the Auto Delete attribute is configured. Valid
      values:

      true: The Auto Delete attribute is configured. If the last queue that is bound
      to an exchange is unbound, the exchange is automatically deleted.

      false: The Auto Delete attribute is not configured. If the last queue that is
      bound to an exchange is unbound, the exchange is not automatically deleted.'
    Type: Boolean
  ExchangeName:
    Description: The name of the exchange.
    MaxLength: 255
    Type: String
  ExchangeType:
    AllowedValues:
    - FANOUT
    - DIRECT
    - TOPIC
    - HEADERS
    Description: 'The type of the exchange. Valid values:

      FANOUT: An exchange of this type routes all the received messages to all the
      queues bound to this exchange. You can use a fanout exchange to broadcast messages.

      DIRECT: An exchange of this type routes a message to the queue whose binding
      key is exactly the same as the routing key of the message.

      TOPIC: This type is similar to the direct exchange type. An exchange of this
      type routes a message to one or more queues based on the fuzzy match or multi-condition
      match result between the routing key of the message and the binding keys of
      the current exchange.

      HEADERS: Headers Exchange uses the Headers property instead of Routing Key for
      routing matching. When binding Headers Exchange and Queue, set the key-value
      pair of the binding property; when sending a message to the Headers Exchange,
      set the message''s Headers property key-value pair and use the message Headers
      The message is routed to the bound Queue by comparing the attribute key-value
      pair and the bound attribute key-value pair.'
    Type: String
  InstanceId:
    Description: InstanceId
    Type: String
  Internal:
    AllowedValues:
    - 'True'
    - 'true'
    - 'False'
    - 'false'
    Description: 'Specifies whether an exchange is an internal exchange. Valid values:

      false: The exchange is not an internal exchange.

      true: The exchange is an internal exchange.'
    Type: Boolean
  VirtualHost:
    Description: The name of the virtual host.
    Type: String
Resources:
  Exchange:
    Properties:
      AutoDeleteState:
        Ref: AutoDeleteState
      ExchangeName:
        Ref: ExchangeName
      ExchangeType:
        Ref: ExchangeType
      InstanceId:
        Ref: InstanceId
      Internal:
        Ref: Internal
      VirtualHost:
        Ref: VirtualHost
    Type: ALIYUN::AMQP::Exchange
Outputs:
  ExchangeName:
    Description: The name of the exchange.
    Value:
      Fn::GetAtt:
      - Exchange
      - ExchangeName

JSON format

{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "InstanceId": {
      "Type": "String",
      "Description": "InstanceId"
    },
    "Internal": {
      "Type": "Boolean",
      "Description": "Specifies whether an exchange is an internal exchange. Valid values:\nfalse: The exchange is not an internal exchange.\ntrue: The exchange is an internal exchange.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "VirtualHost": {
      "Type": "String",
      "Description": "The name of the virtual host."
    },
    "AutoDeleteState": {
      "Type": "Boolean",
      "Description": "Specifies whether the Auto Delete attribute is configured. Valid values:\ntrue: The Auto Delete attribute is configured. If the last queue that is bound to an exchange is unbound, the exchange is automatically deleted.\nfalse: The Auto Delete attribute is not configured. If the last queue that is bound to an exchange is unbound, the exchange is not automatically deleted.",
      "AllowedValues": [
        "True",
        "true",
        "False",
        "false"
      ]
    },
    "ExchangeName": {
      "Type": "String",
      "Description": "The name of the exchange.",
      "MaxLength": 255
    },
    "ExchangeType": {
      "Type": "String",
      "Description": "The type of the exchange. Valid values:\nFANOUT: An exchange of this type routes all the received messages to all the queues bound to this exchange. You can use a fanout exchange to broadcast messages.\nDIRECT: An exchange of this type routes a message to the queue whose binding key is exactly the same as the routing key of the message.\nTOPIC: This type is similar to the direct exchange type. An exchange of this type routes a message to one or more queues based on the fuzzy match or multi-condition match result between the routing key of the message and the binding keys of the current exchange.\nHEADERS: Headers Exchange uses the Headers property instead of Routing Key for routing matching. When binding Headers Exchange and Queue, set the key-value pair of the binding property; when sending a message to the Headers Exchange, set the message's Headers property key-value pair and use the message Headers The message is routed to the bound Queue by comparing the attribute key-value pair and the bound attribute key-value pair.",
      "AllowedValues": [
        "FANOUT",
        "DIRECT",
        "TOPIC",
        "HEADERS"
      ]
    }
  },
  "Resources": {
    "Exchange": {
      "Type": "ALIYUN::AMQP::Exchange",
      "Properties": {
        "InstanceId": {
          "Ref": "InstanceId"
        },
        "Internal": {
          "Ref": "Internal"
        },
        "VirtualHost": {
          "Ref": "VirtualHost"
        },
        "AutoDeleteState": {
          "Ref": "AutoDeleteState"
        },
        "ExchangeName": {
          "Ref": "ExchangeName"
        },
        "ExchangeType": {
          "Ref": "ExchangeType"
        }
      }
    }
  },
  "Outputs": {
    "ExchangeName": {
      "Description": "The name of the exchange.",
      "Value": {
        "Fn::GetAtt": [
          "Exchange",
          "ExchangeName"
        ]
      }
    }
  }
}