Binding a RabbitMQ Exchange
Binding an exchange is to relate an exchange to another exchange or queue. In this way, producers send messages to exchanges and exchanges route these messages to related exchanges or queues.
This section describes how to bind exchanges on the console. An exchange can be bound with a target exchange or a queue can be bound with a source exchange. An exchange can be bound with multiple target exchanges. A queue can be bound with multiple source exchanges.
Notes and Constraints
- In RabbitMQ 3.x.x, the exchange (AMQP default) cannot be bound with any exchange.
- In RabbitMQ AMQP-0-9-1, exchanges can only be bound with queues and not exchanges.
- Internal exchanges can only be bound with exchanges and not queues.
Prerequisites
An exchange has been created.
Binding an Exchange to a Target Exchange
- Log in to the console.
- In the upper left corner, click and select a region.
Select the region where your RabbitMQ instance is.
- Click and choose Middleware > Distributed Message Service for RabbitMQ to open the console of DMS for RabbitMQ.
- Click an instance name to go to the instance details page.
- In the navigation pane, choose Virtual Hosts.
- Click a virtual host name.
- On the Exchange tab page, click Bind Exchange in the row containing the desired exchange. The Bind Exchange page is displayed.
- Click Add Binding. The Add Binding dialog box is displayed.
- Set the parameters by referring to Table 1.
Table 1 Binding parameters Parameter
Description
Type
This parameter is only available in RabbitMQ 3.x.x. RabbitMQ AMQP-0-9-1 supports only queue bindings.
Select the binding type: Select Exchange.
Target
Select a target exchange to be bound.
Routing Key
Enter a key string to inform the exchange of which target exchanges to deliver messages to.
- This parameter is required by direct exchanges and topic exchanges. Such exchanges route messages to target exchanges with the routing keys matched. If this parameter is not set, exchanges route messages to all the bound target exchanges.
- Enabling x-consistent-hash exchanges requires a routing key which indicates the weight of a queue. The larger the key, the heavier the weight, which means that the queue receives more messages.
- For fanout exchanges and header exchanges, skip this parameter.
- Click OK.
On the Bindings page, view the bound exchange.
Binding Source Exchanges to a Queue
- Log in to the console.
- In the upper left corner, click and select a region.
Select the region where your RabbitMQ instance is.
- Click and choose Middleware > Distributed Message Service for RabbitMQ to open the console of DMS for RabbitMQ.
- Click an instance name to go to the instance details page.
- In the navigation pane, choose Virtual Hosts.
- Click a virtual host name.
- On the Queue tab page, click View Detail in the row containing the desired queue.
- On the Bindings tab, click Add Binding. The Add Binding dialog box is displayed.
- Set the parameters by referring to Table 2.
Table 2 Binding parameters Parameter
Description
Source
Select an exchange to be bound.
Routing Key
Enter a key string to inform the exchange of which queues to deliver messages to.
- This parameter is required by direct exchanges and topic exchanges. Such exchanges route messages to queues with the routing keys matched. If this parameter is not set, exchanges route messages to all the bound queues.
- Enabling x-consistent-hash exchanges requires a routing key which indicates the weight of a queue. The larger the key, the heavier the weight, which means that the queue receives more messages.
- For fanout exchanges and header exchanges, skip this parameter.
- Click OK.
On the Bindings tab, view the new exchange.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot