MassTransit 请求响应示例

MassTransit Request Response sample

我正在学习 MassTransit,所以我下载了他们提供的 sample 但是它似乎对我不起作用,当我尝试启动该服务时出现以下错误:

An exception occurred
MassTransit.RabbitMqTransport.RabbitMqConnectionException: Connect failed: igor@localhost:5672/test ---> RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=530, text="NOT_ALLOWED - vhost test not found", classId=10, methodId=40, cause=
   at RabbitMQ.Client.Impl.SimpleBlockingRpcContinuation.GetReply(TimeSpan timeout)

当我尝试使用其他使用旧版本 MassTransit 的示例时,它们工作正常。

示例使用 RMQ URI,其中包括 test 虚拟主机。由于您尚未创建它,因此您的代码失败了,它实际上准确地告诉您 - 未找到虚拟主机 test

这是该示例中的 app.config

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

因此,客户端 uses the same URI, 所以它们都将无法启动。