[rabbitmq-discuss] .net version of the subscriber
Matthias Radestock
matthias at rabbitmq.com
Tue Jan 22 23:46:10 GMT 2013
On 22/01/13 18:43, jdepp wrote:
> I am trying to interprate the following and convert into .net code to
> implement creating multiple consumers and have them subscribe to a queue.
>
> def callback(ch, method, properties, body):
> print " [x] Received %r" % (body,)
> time.sleep( body.count('.') )
> print " [x] Done"
> ch.basic_ack(delivery_tag = method.delivery_tag)
>
> channel.basic_qos(prefetch_count=1)
> channel.basic_consume(callback,
> queue='task_queue')
>
> channel.start_consuming()
>
>
> what is the callback method? Is that the function that is called
yes.
> and how is this faster than using a basicget within your own loop.
I answered that in the other thread.
> It is still one consumer to a queue
Yes. Depending on your definition of 'consumer'. It's certainly just one
client connected to rabbit. And it's certainly just one AMQP consumer
(since there is only one basic.consume method). But it *could*
potentially spawn a new thread for every message received, or use a
thread pool.
> right or does rabbit implement its own threading somehow.
Depends on the client library. There are certainly some that maintain
thread pools for invoking consumer callbacks - the RabbitMQ Java client
is an example - but usually even then only a single thread is used for
all messages arriving for a single AMQP consumer, or even across an
entire channel, since that way messages can be guaranteed to get
processed on order.
Regards,
Matthias.
More information about the rabbitmq-discuss
mailing list