Masstransit RabbitMq Request/Response 无法创建自动删除交换

Masstransit RabbitMq Request/Response cannot create auto-delete exchange

我们正在尝试实现 request/response 消息将被删除的场景 服务器(消费者)已关闭。我们从 rabbit mq 安装中没有交换/队列开始。

有一个服务器创建自己的交换/队列,我们​​希望它是 auto-delete=true

如果服务器先于客户端启动,则使用正确的配置创建交换。但是当客户端启动时,我们会收到此错误:

RabbitMQ.Client.Exceptions.OperationInterruptedException: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'auto_delete' for exchange 'simple_request' in vhost '****': received 'false' but current is 'true'", classId=40, methodId=10, cause=

如果客户端首先启动,并尝试发送消息,则会使用我们定义的队列名称创建交换,但它不是 auto-delete=true,这会导致错误:

RabbitMQ receive transport failed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'auto_delete' for exchange 'simple_request' in vhost '****': received 'true' but current is 'false'", classId=40, methodId=10, cause=RabbitMQ receive transport failed: The supervisor is stopping, no additional scopes can be created

服务器最终启动时。

我们如何在请求响应场景中实现自动删除队列?

您可以在客户端更新服务队列的 URI 以包含查询字符串参数,以便正确创建队列。

rabbitmq://host/vhost/queue?autodelete=true&durable=false

请注意,我包括了 durable=false,但这只是在您使用非持久队列并且我想完整的情况下。