虚拟主机(vhosts) 在 RabbitMQ 中提供了逻辑隔离 — 为队列、交换机和权限提供独立的命名空间。它们允许单个 RabbitMQ 实例服务于多个隔离的应用程序或环境。
虚拟主机是什么
VIRTUAL HOST (vhost) → a logically isolated namespace within a RabbitMQ broker:
→ each vhost has its OWN queues, exchanges, bindings (isolated from other vhosts)
→ its own PERMISSIONS (users granted access per vhost)
→ like separate "virtual brokers" within one physical broker
→ partitions a single RabbitMQ instance into isolated environments
为什么使用虚拟主机
✓ ISOLATION → separate applications/teams/environments on one broker (their queues/exchanges
don't interfere or collide)
✓ MULTI-TENANCY → multiple apps share a broker but stay separated
✓ ENVIRONMENTS → e.g. separate vhosts for dev/staging (on a shared broker)
✓ ACCESS CONTROL → grant users permissions per vhost (security/separation)
✓ Organization → group related messaging resources; avoid name collisions
