Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

rabbitmq

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?

like image 721
omer faruk Avatar asked Aug 03 '16 14:08

omer faruk


2 Answers

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).

like image 186
Alex G. Avatar answered Nov 08 '22 19:11

Alex G.


Read this discussion. Michael Klishin is the maintainer of .NET RabbitMQ client on GitHub.

But if you don't feel like going to different links and reading there I'll summarize...

QueingBasicConsumer does not autorecover in current version, and it was a work around for a message dispatcher issue which no longer exists. But also I think Alexey is right, the performance was probably an issue too with the locking and busy waiting (in most implementations) the queue was introducing.

like image 41
Svet Angelov Avatar answered Nov 08 '22 19:11

Svet Angelov