【问题标题】:QueueingBasicConsumer is deprecated. Which consumer is better to implement RabbitMq .net clientQueueingBasicConsumer 已弃用。哪个消费者更好地实现 RabbitMq .net 客户端
【发布时间】:2016-08-03 14:46:43
【问题描述】:

在 RabbitMQ .NET 客户端中,QueueingBasicConsumer 已弃用。

他们建议改用EventingBasicConsumer。我以与他们相同的方式实现了IQueueingBasicConsumer 接口,并且效果很好。

但是,我很好奇为什么它被弃用以及为什么我应该使用EventingBasicConsumer

【问题讨论】:

    标签: c# rabbitmq


    【解决方案1】:

    我认为(我可能错了!)这样做是出于性能原因。 QueueingBasicConsumer uses SharedQueue<T> 这基本上是带有锁的.NET Queue。为了处理交付,您需要锁定队列、将项目入队并通知等待队列的其他线程(Monitor.Pulse)。

    EventingBasicConsumer doesn't 使用任何排队机制。它只是触发您需要在代码中处理的 Received (HandleBasicDeliver) 事件。

    正如您现在所见,EventingBasicConsumer 的性能开销更少,因此速度更快(应该如此)。

    【讨论】:

    • 感谢您的解释。我只是在我的应用程序中使用QueueingBasicConsumer 作为消息传递模块。我需要更新客户端并使用EventingBasicConsumer 重新实现。
    【解决方案2】:

    阅读此discussion。 Michael Klishin 是 GitHub 上 .NET RabbitMQ 客户端的维护者。

    但是,如果您不想转到不同的链接并在那里阅读,我会总结一下...

    QueingBasicConsumer 在当前版本中不会自动恢复,这是针对不再存在的消息调度程序问题的解决方法。但我也认为 Alexey 是对的,性能可能也是队列引入的锁定和忙等待(在大多数实现中)的问题。

    【讨论】:

      猜你喜欢
      • 2019-07-02
      • 2019-04-21
      • 1970-01-01
      • 1970-01-01
      • 2020-11-02
      • 1970-01-01
      • 1970-01-01
      • 2016-07-05
      • 1970-01-01
      相关资源
      最近更新 更多