简体   繁体   English

每个用户的Spring RabbitMQ连接

[英]Spring RabbitMQ Connection Per User

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. 我有一个多用户Spring Web应用程序,在该应用程序中,我需要每个登录用户都能在其自己的Rabbitmq vHost上接收消息,以便其他任何用户都不能查看其他用户的消息。 I have this working currently with no vHost but every user can get any message. 我目前没有vHost,但每个用户都可以收到任何消息。 By my understanding using a vHost is the simplest way to do this (please correct me if I am wrong). 以我的理解,使用vHost是执行此操作的最简单方法(如果我输入错了,请纠正我)。

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. 这实际上有两个问题,因为在任何人登录之前在浏览器中启动应用程序时它就连接。我试图用vHost解决方案实现动态连接,并且仅在该用户登录后才连接该用户。我在Google上唯一能找到的是使用AbstractRoutingConnectionFactorySimpleRoutingConnectionFactory ,但是我根本找不到如何在线使用它们的示例。

I would really appreciate any help anyone could provide, thanks. 非常感谢任何人可以提供的任何帮助,谢谢。

It seems a little excessive to use a vHost per user; 每个用户使用vHost似乎有点多余; why not just create a queue/exchange for each user? 为什么不为每个用户创建一个队列/交换?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM