Alex P <oleksandr.petrov at> writes:
So far we went with a toolset that's defined in ./examples and ./
tools, but, for instance in example for listenqueue framing is done
manually. Is there a high-level API for receiving a whole message in
case it's there and getting AMQP_BASIC_GET_EMPTY_METHOD or anything
else if body is empty / nothing received?
You're right, the support for consuming messages is quite low-level.

There's no particularly good reason for that, although designing an
efficient general purpose high-level API is non-trivial. You can write
easily write one that meets the needs of your application though, and I
would recommend you do so.

For example, the code in tools/ is able to directly output message
contents from the memory buffers managed by librabbitmq. The copy_body
function in tools/common.c encapsulates this.

But other applications might want to malloc a single block of memory for
each incoming message body, and copy the body data from the frames into
that. Etc.
amqp_basic_get(conn, 1, queue, 1); seemed to be a good candidate for
that, but still in it's marked as one of those methods that
should not be exposed as an API.
amqp_basic_get is exposed as an API. It's defined in amq_api.c, and is
definitely intended for use by applications.

It is marked for special handling in simply because the
autogenerated definition would not be correct (the comment there is
misleading; the real issue is that basic.get has two possible responses:
So, my question would be - what is the best way to receive messages?
Should we handle framing manually, as it's done in examples? If not,
what are the api methods that we should stick to?
Do it manually, but by writing your own code to encapsulate the
low-level frame handling. librabbitmq might get a higher-level API one
day, and by encapsulating the code that uses the current API, you'll
find it easier to transition.


David Wragg
Staff Engineer, RabbitMQ
VMware, Inc.

Search Discussions

Discussion Posts


Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 6 | next ›
Discussion Overview
grouprabbitmq-discuss @
postedSep 2, '11 at 10:35a
activeSep 2, '11 at 9:37p

2 users in discussion

Alex P: 4 posts David Wragg: 2 posts



site design / logo © 2022 Grokbase