[rabbitmq-discuss] Publish on a queue, then Monitor on a reply queue, with only 1 connection to the RabbitMQ server? Non-blocking?
Gavin M. Roy
gmr at myyearbook.com
Wed Sep 7 20:46:18 BST 2011
On Wednesday, September 7, 2011 at 2:45 PM, Christopher Lefevre wrote:
> Only using one connection is the point of this modification.
>
>
>
Oh that's easy then.
> I already have a setup that does an asynchronous call that instantiates a Pika Publisher to publish a message to the queue, and a Pika Monitor to consume messages. However those each create their own connection and ioloops.
>
>
>
No need for that.
> Am I chasing my tail trying to get multiple channels created for a single connection? Then creating a queue on each channel, one to monitor, one to publish to?
You don't need a channel per queue really, but it should be easy to create -- this is more pseudocode, but should get the spirit across:
conn = FooConnection(on_connection_open)
conn.ioloop.start()
def on_connection_open(conn):
conn.channel(on_channel_one_open)
conn.channel(on_channel_two_open)
def on_channel_one_open(channel):
global channel_one
channel_one = channel
channel_one.create_queue(on_monitor_queue_created)
def on_monitor_queue_created(frame)
channel_one.basic_consume('routing_key', monitor_consumer_function)
def on_channel_two_open(channel):
global channel_two
channel_two = channel
for x in xrange(0, 10000):
publish_consumer_function(x)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110907/4e010739/attachment.htm>
More information about the rabbitmq-discuss
mailing list