[rabbitmq-discuss] Create many queues with Pika

Raphaël De GIUSTI raphael.degiusti at guardis.com
Mon Mar 19 15:02:42 GMT 2012


Hello everyone,

I'm in a situation where I need to create a lot of queues, let's say 20,
using Pika 0.9.5.
I'm currently using the SelectConnection module which works with callbacks.

I don't want to cascade 20 consecutive callbacks to achieve this:

def on_channel_open(channel_):
>     global channel
>     channel = channel_
>     channel.queue_declare(queue="queue1", durable=True,
>                               exclusive=False, auto_delete=False,
>                               callback=on_queue_1_declared)
> def on_queue_1_declared(frame):
>     channel.queue_declare(queue="queue2", durable=True,
>                               exclusive=False, auto_delete=False,
>                               callback=on_queue_2_declared)
> def on_queue_2_declared(frame):
>     channel.queue_declare(queue="queue3", durable=True,
>                               exclusive=False, auto_delete=False,
>                               callback=on_queue_3_declared)
> def on_queue_3_declared(frame):
>     channel.queue_declare(queue="queue4", durable=True,
>                               exclusive=False, auto_delete=False,
>                               callback=on_queue_4_declared)


And so on...

This is not pretty. Any idea on how to achieve this without declaring all
those callbacks ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20120319/755da90d/attachment.htm>


More information about the rabbitmq-discuss mailing list