Updated on 2025-11-20 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

Notes and Constraints

Table 1 Notes and constraints

Version

Notes and Constraints

3.x.x

  • After an instance is created, a virtual host named / is automatically created.
  • When a virtual host name starts with a special character, such as a period (.), the monitoring data may not be displayed. When a virtual host name contains special characters such as percent (%), vertical bar (|), or slash (/), this name is not consistently displayed on the monitoring page. The special characters are displayed as underscores (_) instead. For example, virtual host Vhost.1%1|2_3/ is displayed as Vhost.1_1_2_3_ in monitoring.
  • On Cloud Eye, a special character (.) is counted as five characters. If the name of a queue or virtual host contains periods (.) and the counted total length exceeds 256 characters, the monitoring data may not be displayed.
  • Virtual hosts can be created on the console and management UI.

AMQP-0-9-1

  • After an instance is created, a virtual host named default is automatically created.
  • When a virtual host name contains special characters such as percent (%), vertical bar (|), slash (/), or period (.), this name is not consistently displayed on the monitoring page. The special characters are displayed as underscores (_) instead. For example, virtual host Vhost.1%1|2_3/ is displayed as Vhost_1_1_2_3_ in monitoring.
  • Virtual hosts can be created only on the console.

Creating a RabbitMQ Virtual Host

A virtual host can be created on the console or management UI.

  1. Log in to the RabbitMQ console.
  2. Click in the upper left corner to select the region where your instance is located.
  3. Click an instance name to go to the instance details page.
  4. In the navigation pane, choose Instance > Virtual Hosts.
  5. Click Create Virtual Host.
  6. Enter a virtual host name and click OK.

    Table 2 Virtual host naming rules

    Version

    Naming Rule

    3.x.x

    The value can contain 2 to 128 characters, including letters, digits, periods (.), percent signs (%), vertical bars (|), hyphens (-), underscores (_), and slashes (/).

    AMQP-0-9-1

    The value can contain 2 to 32 characters, including letters, digits, periods (.), percent signs (%), vertical bars (|), hyphens (-), underscores (_), and slashes (/). (Each special character is counted as three characters.)

    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.x.x. If it is enabled, you can trace the message forwarding path.
    Figure 2 Virtual host list (RabbitMQ 3.x.x)
    Figure 3 Virtual hosts (RabbitMQ AMQP-0-9-1)

  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)

Related Document

To create a virtual host by calling an API, see Creating a Virtual Host.