On 1 August 2014 at 11:57:34, Emiel Bruijntjes (
emiel.br...@gmail.com) wrote:
> > As far as I understand, "basic.get" is a synchronous call, which
> means that our client MUST wait for an answer, before it can send
> a next frame over the same channel to the RabbitMQ server. It is
> thus not permitted to send multiple instructions right after
> the basic.get frame, if no answer has yet been received (am I right
> on this?)
>
> The answer to the "basic.get" frame is either a "basic.get-ok"
> or "basic.get-empty" frame. Is it allowed to send the next instruction
> to RabbitMQ immediately after we've received either of these
> two frames (and even before the entire body has been received),
> or should we (in case of a "basic.get-ok" frame) also wait for
> all the "body" frames to be received before we can proceed with
> sending further frames?
Sections 2.2.2, 3.2.1, and 4.7 in [1] leave interpretation largely up to the reader ;)
My understanding of this (and how Java, .NET, Ruby clients work):
after sending basic.get, the client enter a "continuation" and may receive either an async method (e.g. basic.deliver, channel.close,
or, in case of RabbitMQ, basic.[n]ack if publisher confirms are enabled). Those are
dispatched as usual. Response methods (basic.get-ok, basic.get-empty) release the continuation,
as does TCP connection failure or channel error. Such client API won't let you issue e.g. a
queue.declare right after basic.get w/o receiving a response (unless you share a channel between
threads, which is problematic in many ways). This is also how it works for all
synchronous methods, e.g. queue.declare.
basic.get-ok carries a body, so content header
and 0 or more body frames will always follow it and must be considered a part of the method.
As the spec mentions, methods used in performance sensitive
cases (e.g. publishing) are usually asynchronous, and our experience with multiple clients
suggest that in practice this blocking continuations approach works well.
I hope this answers your question.
1.
http://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf
--
MK
Staff Software Engineer, Pivotal/RabbitMQ