[rabbitmq-discuss] pika.channel.basic_consume
Marcin Krol
mrkafk at gmail.com
Thu Jan 27 19:52:16 GMT 2011
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello everyone,
Can channel.basic_consume handle more than 1 callback?
Reading channel.py would suggest so:
def basic_consume(self, consumer, queue = '', no_ack = False, exclusive
= False, consumer_tag = None):
tag = consumer_tag
...
self.callbacks[tag] = consumer
But when I use more than one callback (both on exclusive queues), only
one of them works.
def setup_distrib(node):
global chan, conn, myqueue, rpc_res_exch, rpc_send_exch
chan.exchange_declare(exchange = rpc_send_exch,type='fanout')
chan.exchange_declare(exchange = rpc_res_exch,type='direct')
res = chan.queue_declare(exclusive = True)
myqueue = res.queue
print 'myqueue', myqueue
# important! when binding queue to direct exchange, a proper routing
key must be given!
chan.queue_bind(exchange = rpc_res_exch, queue = myqueue,
routing_key = myqueue)
chan.basic_consume(on_response_distrib, no_ack=True, queue=myqueue)
def setup_rdonly(node):
global chan, conn, myqueue, rpc_rdonly_res_exch,
rpc_rdonly_send_exch, rdonlysendqueue
chan.exchange_declare(exchange = rpc_rdonly_send_exch, type='direct')
chan.exchange_declare(exchange = rpc_rdonly_res_exch, type='direct')
rdonlysendqueue = node + '_rdonly'
chan.queue_declare(queue=rdonlysendqueue)
chan.queue_bind(exchange=rpc_rdonly_send_exch,
queue=rdonlysendqueue, routing_key=rdonlysendqueue)
res = chan.queue_declare(exclusive=True)
myqueue = res.queue
print 'myqueue', myqueue
chan.queue_bind(exchange=rpc_rdonly_res_exch, queue=myqueue,
routing_key=myqueue)
chan.basic_consume(on_response_rdonly, no_ack=True, queue=myqueue)
When I do setup_distrib(node) AND setup_rdonly(node), only rdonly queues
work.
When I do one or the other, either works.
Anybody?
- --
Regards,
mk
- --
Premature optimization is the root of all fun.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iQEcBAEBAgAGBQJNQczwAAoJEFMgHzhQQ7hOdQEH/ia0zoybB6WDiaxXO/KRib6c
xemppCBnYUq0oJvLxkwpPSIyMNjVPgML7klXS02ecVVJ+S69e6ztWJuiESL2jHo+
Uarz+TxlRKrFlHoRST1gQlIIwloJURFcdlX26yPocBYfSayJH8sGxFFsE9XUh2Yj
N361XYkETc20xr0+LwpY2BRXT/8/WtH/xBw+1KGCOkvnF0hbOFw0YD/zHsT4UnIT
kdI0zNy0/+6kGg/IhrSwBwc+EKT6O/b7o08s0/Ov3M+i4mYrd23JR+CB55EW6spe
d/hbAdUu8hZaS634iNOMsZG8XHH5Ztv+MjOEhPe/99dPxxLQVJaNxz2C+IsUl44=
=ePoS
-----END PGP SIGNATURE-----
More information about the rabbitmq-discuss
mailing list