使用 MassTransit Sample-RequestResponse 示例拒绝访客访问虚拟主机

access to vhost refused for guest, with the MassTransit Sample-RequestResponse sample

我在最新的 RabbitMQ 服务器上使用默认配置(来宾是管理员)但是当我 运行 RequestResponse 示例时我得到下一个异常。

OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=530, text="NOT_ALLOWED - access to vhost 'test' refused for user 'guest'", classId=10, methodId=40, cause=

有什么想法吗?

样本正确。 App.config中的设置为:

<add key="RabbitMQHost" value="rabbitmq://localhost/test"/>

表示MT会尝试连接本地实例,test虚拟主机。开箱即用的 RabbitMQ 没有配置虚拟主机,这就是您收到此异常的原因。

你可以做的是,使用管理插件:

  1. test 虚拟主机添加到您的 RabbitMQ 服务器配置中
  2. 为您的 guest 用户添加对该虚拟主机的完全权限

然后它将与 App.config 一起使用而无需更改。