[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:17:30 BST 2011


Thanks Gavin, that actually seems to be exactly what I had tried previously, but didn’t work correctly.

Going to re-investigate that solution that I tried and see if I just missed something in there.

One thing that I notice actually, is  you’ve declared 2 globals, which I have implemented differently, the on_open function I have is defined as: def _on_channel_open(self, channel_, callback_=None):

Which then assigned channel_ to self.channel

When I implemented the change, I had self.channel, and self.monitor_channel. However everything else looks the same. Going to have to put all of that back in at this point to double check my work. I had reverted at this point to look into alternative solutions.


-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/0b060948/attachment.htm>


More information about the rabbitmq-discuss mailing list