omer faruk omer faruk - 3 months ago 68
C# Question

QueueingBasicConsumer is deprecated. Which consumer is better to implement RabbitMq .net client

In the RabbitMQ .NET client,

QueueingBasicConsumer
is deprecated.

They recommend to use
EventingBasicConsumer
instead. I implemented the
IQueueingBasicConsumer
interface for the same way they did and it works well.

However, I am curious to why it is deprecated and why I should use
EventingBasicConsumer
?

Answer

I think (I might be wrong!) it's done because of performance reasons. QueueingBasicConsumer uses SharedQueue<T> which is basically .NET Queue with locks. In order to handle a delivery, you need to lock on queue, enqueue an item and notify other threads waiting for the queue (Monitor.Pulse).

EventingBasicConsumer doesn't use any queueing mechanism. It simply fires Received (HandleBasicDeliver) event which you need to handle in your code.

As you can see now EventingBasicConsumer has less performance overhead, so it's faster (it should be).