Todos os produtos
Search
Central de documentação

Resource Orchestration Service:ALIYUN::AMQP::Exchange

Última atualização: Jun 27, 2026

Crie um exchange em uma instância do ApsaraMQ for RabbitMQ.

Sintaxe

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

Propriedades

Propriedade

Tipo

Obrigatório

Editável

Descrição

Restrição

AutoDeleteState

Boolean

Sim

Não

Defina se o exchange será excluído automaticamente.

Valores válidos:

  • true: o sistema exclui o exchange automaticamente ao desvincular a última fila associada.

  • false: o sistema não exclui o exchange automaticamente ao desvincular a última fila associada.

ExchangeName

String

Sim

Não

Nome do exchange.

  • O nome deve ter de 1 a 255 caracteres e conter apenas letras, dígitos, hifens (-), underscores (_), pontos (.), cerquilhas (#), barras (/) e arrobas (@).

  • Não é possível modificar o nome após a criação do exchange. Para renomeá-lo, exclua-o e crie um novo.

ExchangeType

String

Sim

Não

Tipo do exchange.

Valores válidos:

  • DIRECT: roteia a mensagem para a fila cuja chave de vinculação corresponde exatamente à chave de roteamento da mensagem.

  • TOPIC: semelhante ao exchange direto, mas roteia a mensagem para uma ou mais filas com base em correspondência difusa ou de múltiplas condições entre a chave de roteamento e as chaves de vinculação.

  • FANOUT: roteia todas as mensagens recebidas para todas as filas vinculadas. Use este tipo para transmitir mensagens.

  • HEADERS: similar ao exchange direto, porém roteia mensagens com base nos atributos de cabeçalho em vez de chaves de roteamento. Tanto os atributos de vinculação quanto os cabeçalhos da mensagem são definidos como pares chave-valor, e o exchange os compara para determinar o roteamento.

InstanceId

String

Sim

Não

ID da instância.

Nenhuma.

Internal

Boolean

Sim

Não

Indica se o exchange é interno.

Valores válidos:

  • true

  • false

VirtualHost

String

Sim

Não

Vhost onde criar o exchange.

Nenhuma.

AlternateExchange

String

Não

Não

Exchange alternativo.

Um exchange alternativo recebe mensagens que não puderam ser roteadas para nenhuma fila a partir do exchange atual.

XDelayedType

String

Não

Não

Tipo de exchange para entrega de mensagens atrasadas.

Use o cabeçalho x-delay para definir um atraso em milissegundos antes da entrega da mensagem por um exchange x-delayed-message. A regra de roteamento varia conforme o tipo de exchange especificado nesta propriedade. Valores válidos:

  • DIRECT: entrega mensagens atrasadas às filas vinculadas a um exchange direto.

  • TOPIC: entrega mensagens atrasadas às filas vinculadas a um exchange de tópico.

  • FANOUT: entrega mensagens atrasadas às filas vinculadas a um exchange fanout.

  • HEADERS: entrega mensagens atrasadas às filas vinculadas a um exchange de cabeçalhos.

  • X-JMS-TOPIC: entrega mensagens atrasadas às filas vinculadas a um exchange x-jms-topic.

Valores de retorno

Fn::GetAtt

ExchangeName: nome do exchange.

Exemplos

Formato YAML

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

Formato JSON

{
  "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"
        ]
      }
    }
  }
}