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

Marek Majkowski majek04 at gmail.com
Tue Sep 6 17:43:03 BST 2011


On Tue, Sep 6, 2011 at 17:19, Christopher Lefevre
<CLefevre at transparent.com> wrote:
> To note, if this is an easier description, I’m trying to implement the RPC
> example on the RabbitMQ tutorial with a synchronous connection. Which I’ve
> copied below so you guys don’t need to go find it. However, the main impetus
> to me moving forward is lines 13/14:
>
>         result = self.channel.queue_declare(exclusive=True)
>
>         self.callback_queue = result.method.queue

Synchronous methods in AMQP return data. This data is captured
under 'result.method'.
result.method.queue contains a fresh, unique, exclusive queue name
that was just created.

> Line 13 declares the result variable as the product of the channel getting
> an exclusive queue created, which I get. However the part that I get caught
> up in is where the callback is set to result.method.queue in line 14. What
> exactly is the method.queue of the result object?

If you're interested in other fields under 'result.method' please take a look
at amqp spec, for example results of queue-declare are under queue-declare-ok
method: http://www.rabbitmq.com/amqp-0-9-1-reference.html#queue.declare-ok

> I am hoping to simply
> modify my Monitor/Publish classes to be able to have a synchronous
> publish/monitor without creating 2 connections. My current attempt at simply
> using one connection with 2 channels does not seem to be operating how I
> expected.

The problem is that RPC client does only listen for messages when
there is an RPC call running. So, you won't be able to get 'realtime'
data from other things that are hanging on the same connection.
You may hear the results only during the rpc call.

Cheers,
  Marek


More information about the rabbitmq-discuss mailing list