.net - EasyNetQ - EasyNetQ.Topology.Queue

标签 .net rabbitmq easynetq

有人可以解释一下 EasyNetQ.Topology.Queue 类型的构造函数的参数 isExclusive 的用法吗?

注意:需要实例化此类型才能使用高级 API 删除队列。

最佳答案

来自AMQP docs

"Exclusive queues may only be accessed by the current connection, and are deleted when that connection closes. Passive declaration of an exclusive queue by other connections are not allowed."

在删除队列之前检查队列是否存在是个好主意。进行被动声明(如果队列不存在,则不会创建队列)将返回一个 IQueue 实例,然后您可以使用该实例删除它,并且不必担心 isExclusive 参数:

// may throw if queue doesn't exist
var queue = advancedBus.QueueDeclare("my.queue.name", passive = true);
advancedBus.QueueDelete(queue);

顺便说一句。 IQueue 的 isExclusive 参数未在 IAdvancedBus.Delete(..) 方法中使用,因此您可以愉快地忽略它(但需要注意的是,这在未来版本中可能会发生变化)。

关于.net - EasyNetQ - EasyNetQ.Topology.Queue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21822683/

相关文章:

c# - O(1) 哈希查找?

windows - 运行 rabbitmq-server 时出现路径错误

c# - EasyNetQ/RabbitMq : How to prevent duplicate message handling during debug?

c# - 内部方法和数据结构。

c# - 如何使基类中的隐藏属性只获取

java - RabbitMQ 连接处于阻塞状态?

c# - RabbitMQ basic.return

asp.net-web-api - RabbitMQ 与 Web API + SignalR

c# - C# 中 MySQL 查询出错?