Parallel processing / Threading in rabbitmq

353 views
Skip to first unread message

Arif Pathan

unread,
Dec 8, 2017, 1:44:33 AM12/8/17
to rabbitmq-users
 var consumer = new EventingBasicConsumer(channel);
 channel.QueueDeclare(QueueName, true, false, false);
 channel.BasicConsume(queue: QueueName, autoAck: false, consumer: consumer);
 consumer.Received += (model, ea) =>
 {
//do something
}


vs

channel.ExchangeDeclare(ExchangeName, "topic");
channel.QueueDeclare(QueueName,false, false, true, null);
channel.QueueBind(QueueName, ExchangeName, topicroutingKey);
channel.BasicQos(0, 10, false);
Subscription subscription = new Subscription(channel, QueueName, false);
while (true)
   {
     BasicDeliverEventArgs deliveryArguments = subscription.Next();
//do something
}


Is a new thread started in both of them ??
at
consumer.Received += (model, ea) => {//do something}
and
BasicDeliverEventArgs deliveryArguments = subscription.Next();

Or is it in none of them, Pros and cons of using above two approaches
Any inputs/suggestions are welcome, 

Michael Klishin

unread,
Dec 8, 2017, 12:46:17 PM12/8/17
to rabbitm...@googlegroups.com
You should not be using Subscription or QueueingBasicConsumer. They have both been deprecated a long time ago
and have no reason to exist with modern versions of the client.

.NET client uses a thread pool (and you can provide your own) for consumer operation dispatch. The above
classes are special cases but in general no, each consumer isn't starting a new thread.

There are many nuances to the above statement as of https://github.com/rabbitmq/rabbitmq-dotnet-client/pull/307,
which is an alternative implementation you have to opt in to use.

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages