[rabbitmq-discuss] RabbitMQ-C: amqp_simple_rpc blocks waiting for frames already received
David Wragg
david at rabbitmq.com
Thu Jul 21 11:50:32 BST 2011
Clint Miller <clint at rtcreativegroup.com> writes:
> I'm having a little trouble with the RabbitMQ-C library. I'm able to
> declare exchanges, queues, setup bindings, and start the basic.consume
> (amqp_simple_rpc function) method as I would expect.
You are calling the amqp_basic_*, amqp_queue_* and amqp_exchange_*
functions, right? amqp_simple_rpc is best thought of as an internal
function, and calling it directly should never be necessary these days.
None of the sample code in the tools/ and examples/ directories uses it.
> But when a message is received by the consumer, I am able to observe
> (via the debugger) the complete message (all the frames) being
> processed. However, loop where multiple frames are linked together in
> the amqp_simple_rpc function (labeled "retry:") never terminates, and
> thus, at the end of what I think is a correct processing of all the
> frames in the message, control goes back into the wait_frame_inner
> function, where the recv function is called, anticipating more raw
> data on the socket that isn't going to arrive.
amqp_simple_rpc doesn't process incoming messages. If it gets an
incoming frame that doesn't relate to the method, it stashes that frame
away for later handling, and waits for the next frame (as the reply
method frame should arrive sooner or later).
To consume messages via basic.get, use amqp_basic_get and then
amqp_simple_wait_frame to receive the body (see tools/get.c).
To consume messages via basic.consume, use amqp_basic_consume and then
call amqp_simple_wait_frame in a loop (see tools/consume.c and
examples/amqp_consumer.c).
--
David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.
More information about the rabbitmq-discuss
mailing list