tencent cloud

Creating an Exchange
Last updated:2026-01-05 10:10:50
Creating an Exchange
Last updated: 2026-01-05 10:10:50
In a RabbitMQ cluster, the exchange is responsible for receiving and distributing messages. When a producer sends a message, it is not delivered directly to a queue but is first sent to the exchange. The exchange locates matching queues based on the Routing Key: If a matching queue is found, the message is stored. Otherwise, the message is either discarded or sent to a secondary exchange.
Different types of exchanges (such as direct, fanout, and topic) employ distinct routing rules to determine how messages are distributed. For a detailed routing rule introduction, see Exchanges.

Constraints and Limitations

Limitation Type
Managed Edition
Serverless Edition
Quantity limit
A vhost supports the creation of up to 1000 exchanges.
A vhost supports the creation of up to 100 exchanges.
Default exchange limitation
After a vhost is created, 8 default exchanges are preset: (AMQP default exchange), amq.direct, amq.fanout, amq.headers, amq.match, amq.rabbitmq.event, amq.rabbitmq.trace, and amq.topic. These cannot be deleted. Among them:
The AMQP default exchange is bound to every queue by default, with the Routing Key equal to the queue name. This binding relationship cannot be canceled or deleted.
amq.rabbitmq.event is used for event queries and is bound to the default queue named tdmq_event_handle by default.
amq.rabbitmq.trace is used for message tracing.
After a vhost is created, a default exchange named "amq.default" is preset and cannot be deleted.

Prerequisites

You have created a corresponding vhost. For specific steps, see Creating a Vhost.

Operation Steps

1. Log in to the TDMQ for RabbitMQ console.
2. In the left sidebar, choose Cluster > Exchange. Select the target vhost and click Create to go to the Create Exchange page.
3. In the Create Exchange dialog box, enter the following information.
Managed Edition
Serverless Edition
Parameter
Description
Current Vhost
Indicates which vhost the exchange is being created for.
Exchange name
Enter an exchange name. It must be 1 to 64 characters in length and can only contain letters, digits, periods (.), hyphens (-), and underscores (_).
The exchange name cannot be modified after being created.
Routing Type
There are four types: direct, fanout, topic, and headers. The routing type cannot be changed after being selected. For details about routing types, see Exchanges.
direct: This type of exchange routes messages to queues where the Routing Key exactly matches the Binding Key.
fanout: This type of exchange routes messages to all queues bound to it.
topic: This type of exchange supports multi-condition matching and fuzzy matching. It routes messages to the queues bound to it by using the Routing Key pattern matching and string comparison methods.
headers: It has nothing to do with the Routing Key. The matching mechanism involves matching the headers property information in the message. Before a queue is bound to a header exchange, a map key-value pair is declared to bind the message queue to an exchange through this map object. When a message is sent to RabbitMQ, the headers of the message will be obtained and matched with the key-value pair specified when the exchange is bound. If they are exactly matched, the message will be routed to the queue. Otherwise, it will not be routed to the queue.
x-delayed-message: This is a custom exchange type designed for delayed message delivery. When a message is sent to an x-delayed-message exchange, a delay time can be set for the message. RabbitMQ will route the message to its bound queue after the delay time expires. This exchange type allows you to control when messages are sent to consumers, enabling scheduled and delayed message processing.
Note:
To create this type of exchange, see the instructions below:
x-delayed-message is not a built-in RabbitMQ type. You need to enable the rabbitmq_delayed_message_exchange plugin. For details, see Managing Plugins. After enabling this plugin, you can select the x-delayed-message type when creating an exchange in the console.
Durable
Whether to enable exchange persistence:
If it is set to true, the exchange will persist after a service restart.
If it is set to false, the exchange will be deleted after a service restart and needs to be recreated.
AutoDelete
Whether to enable automatic deletion of the exchange:
If it is set to true, the exchange will be automatically deleted when the last queue bound to it is unbound.
If it is set to false, the exchange will not be deleted when the last queue bound to it is unbound.
Internal
Whether the exchange is for internal use by RabbitMQ:
If it is set to true, the exchange cannot be directly used by producers. Publishing messages directly to it will return an error. A routing chain can be established by binding it to other exchanges or queues.
Exchange Description
Enter an exchange description, with a maximum of 128 characters.
Add Secondary Exchange
Optional. By default, the secondary exchange is not used. Messages sent to the primary exchange that cannot be routed will be sent to the secondary exchange specified here.
Parameter
Description
Current Vhost
Indicates which vhost the exchange is being created for.
Exchange Name
Enter an exchange name. It must be 1 to 64 characters in length and can only contain letters, digits, periods (.), hyphens (-), and underscores (_).
The exchange name cannot be modified after being created.
Routing Type
There are five types: direct, fanout, topic, headers, and x-delayed-message. The routing type cannot be changed after being selected. For details about routing types, see Exchanges.
direct: This type of exchange routes messages to queues where the Routing Key exactly matches the Binding Key.
fanout: This type of exchange routes messages to all queues bound to it.
topic: This type of exchange supports multi-condition matching and fuzzy matching. It routes messages to the queues bound to it by using the Routing Key pattern matching and string comparison methods.
headers: It has nothing to do with the Routing Key. The matching mechanism involves matching the headers property information in the message. Before a queue is bound to a header exchange, a map key-value pair is declared to bind the message queue to an exchange through this map object. When a message is sent to RabbitMQ, the headers of the message will be obtained and matched with the key-value pair specified when the exchange is bound. If they are exactly matched, the message will be routed to the queue. Otherwise, it will not be routed to the queue.
x-delayed-message: This is an exchange type designed for delayed message delivery. When sending a message to an x-delayed-message exchange, you can attach a special x-delay header to declare a delivery delay time (in milliseconds). Upon receiving the message, the exchange does not route it immediately but temporarily stores it. Only after the specified delay period elapses will RabbitMQ deliver the message to the target queue, making it visible to consumers and enabling scheduled or delayed message processing.
Exchange Description
Enter an exchange description, with a maximum of 128 characters.
4. Click Submit to complete the exchange creation. The created exchange can be viewed in the exchange list.

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback