[rabbitmq-discuss] Pika blocking receive does not block
irrer at umich.edu
Fri Jul 22 19:12:29 BST 2011
I'm trying to implement a blocking client that does an RPC style call to a
server and get a result. Currently my client sends a message that the
receives, and then the client immediately checks for a response using
basic_consume. The basic_consume method is executed before the
server can respond, and returns without getting a result.
If I add a 'sleep' before the basic_consume, everything works fine, but
that is a poor solution. I want to block until there is something on the
queue to read.
outline of the code:
use channel.queue_declare to declare the reply queue
use queue_bind to bind the reply queue to a unique string
call basic_consume to set up the reply queue handler (I thought that this
would block but it does not)
use basic_publish to send a message to the server, with the reply_to
property set to the unique string
sleep long enough for server to process message (do not want to do this, but
if I don't then I get no reply)
call basic_get (not sure why, but it makes things work)
I have some holes in my understanding, but to not know how to make the
program wait until there is something on the queue and then read it.
Thanks for any hints,
Jim Irrer irrer at umich.edu (734) 647-4409
University of Michigan Hospital Radiation Oncology
519 W. William St. Ann Arbor, MI 48103
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss