Question

I have a multi user Spring web application in which I need each logged in user to be able to receive messages on their own rabbitmq vHost so no other user can view another users message. I have this working currently with no vHost but every user can get any message. By my understanding using a vHost is the simplest way to do this (please correct me if I am wrong).

Currently it is setup like this.

 <!-- Connection Factory -->
<bean id="rabbitConnFactory"
      class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
    <constructor-arg><value>localhost</value></constructor-arg>
    <property name="username" value="guest" />
    <property name="password" value="guest" />
    <property name="virtualHost" value="/" />
    <property name="port" value="5672" />
</bean>

That actually has two problems as it connects when the application is launched in a browser before anyone even logs in. I am trying to wrap my head around implementing the dynamic connection with vHost solution and only connecting per that user once he logs in. So far the only thing I could find on google was the SimpleRoutingConnectionFactory using the AbstractRoutingConnectionFactory, however I can find no example of how to use them online at all.

I would really appreciate any help anyone could provide, thanks.

Was it helpful?

Solution

It seems a little excessive to use a vHost per user; why not just create a queue/exchange for each user?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top