Is VirtualHost a good pattern in RabbitMQ?

User picture User · Jan 31, 2015 · Viewed 11.4k times · Source

I have 100 clients. Each client has unique username, password and two channels (users can't connect to different channels apart from their own). Should I create VirtualHost for each user?

How to write proper user permission to the below situation?:

  • my_user can connect only to vahost called user_vhost using username and password
  • my_user can consume only from the user_channel channel
  • my_user can publish only to the user_channel channel
  • my_user can connect remotely

Thank You!

Answer

hveiga picture hveiga · Jan 31, 2015

Virutal host in RabbitMQ is more like a logical container where a user connected to a particular virtual host cannot access any resource (exchange, queue...) from another virtual host. I always think about it like a administrative domain kind of thing.

Based on what you have explained, I think having a virtual host per user is a good way to keep things simple and clean. Also, this way you do not need to come up with complicated permissions rules, just grant permissions based on virtual host.