Updated on 2024-09-18 GMT+08:00

Creating a RabbitMQ Virtual Host

Each virtual host serves as an independent RabbitMQ server. Virtual hosts provide logical separation of exchanges, queues, and bindings. Different applications run on different virtual hosts without interfering with each other. An instance can have multiple virtual hosts, and a virtual host can have multiple exchanges and queues. To connect a producer or consumer to a RabbitMQ instance, you must specify a virtual host. For details, see Virtual Hosts on the official RabbitMQ website.

Figure 1 Virtual host architecture

Methods of creating a virtual host:

The two methods are supported in RabbitMQ 3.8.35. Virtual hosts can be created for RabbitMQ AMQP-0-9-1 instances only on the console.

After an instance is created, a virtual host named / is automatically created.

After an instance is created, a virtual host named / is automatically created in RabbitMQ 3.8.35 and a virtual host named default is automatically created in RabbitMQ AMQP-0-9-1.

Creating a RabbitMQ RabbitMQ Host (Console)

  1. Log in to the console.
  2. In the upper left corner, click and select a region.

    Select the region where your RabbitMQ instance is.

  3. Click and choose Middleware > Distributed Message Service for RabbitMQ to open the console of DMS for RabbitMQ.
  4. Click an instance name to go to the instance details page.
  5. In the navigation pane, choose Virtual Hosts.
  6. Click Create Virtual Host.
  7. Enter a virtual host name and click OK.

    Once a virtual host is created, its name is fixed and it is displayed in the virtual host list.

    Tracing indicates whether message tracing is enabled. This parameter is available only in RabbitMQ 3.8.35. If it is enabled, you can trace the message forwarding path.
    Figure 2 Virtual host list (RabbitMQ 3.8.35)
    Figure 3 Virtual hosts (RabbitMQ AMQP-0-9-1)

Creating a RabbitMQ Virtual Host (Management UI)

  1. Log in to the RabbitMQ management UI.
  2. On the top navigation bar, choose Admin.
  3. In the navigation tree on the right, choose Virtual Hosts.

    Figure 4 Virtual hosts

  4. In the Add a new virtual host area, enter the virtual host name and click Add virtual host.

    Figure 5 Creating a virtual host (management UI)

    After the creation is successful, the new virtual host is displayed in the All virtual hosts area.

    Figure 6 Virtual host list (management UI)