[rabbitmq-discuss] Publish on a queue, then Monitor on a reply queue, with only 1 connection to the RabbitMQ server? Non-blocking?

Christopher Lefevre CLefevre at Transparent.com
Wed Sep 7 21:49:15 BST 2011


Well, it all works now, thanks!

It apprears my previous implementation simply had some mix-up in the channels or something. I believe what it may have been is when I did the line for: channel.basic_qos(prefetch_count=1)

I may have not actually used the proper channel name there and simply applied it to the same channel twice.


-Christopher Lefevre

From: Gavin M. Roy [mailto:gmr at myyearbook.com]
Sent: Wednesday, September 07, 2011 3:46 PM
To: Christopher Lefevre
Cc: Marek Majkowski; rabbitmq-discuss at lists.rabbitmq.com
Subject: Re: [rabbitmq-discuss] Publish on a queue, then Monitor on a reply queue, with only 1 connection to the RabbitMQ server? Non-blocking?



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)

The information contained in this electronic message and any attached document(s) is intended only for the personal and confidential use of the designated recipients named above. This message may be confidential. If the reader of this message is not the intended recipient, you are hereby notified that you have received this document in error, and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify sender immediately by telephone (603) 262-6300 or by electronic mail immediately. Thank you.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110907/2baa89c9/attachment.htm>


More information about the rabbitmq-discuss mailing list