You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Jonathan Robie <jo...@redhat.com> on 2009/04/23 23:06:46 UTC

[c++]: Message API

In addition to streaming, I think we need to make it easier to encode 
data using AMQP types (for portability). The framing::Buffer class has a 
nice, but incomplete set of methods for doing this:

framing::buffer b;
b.putMediumString("This is a medium string");
b.putShort(i);
b.putDouble(22.0 / i);

But you have to watch out not to overrun the buffer, I haven't figured 
out a way to get that buffer into message content without making an 
extra copy, and converting a buffer to a string is not the most obvious 
way to send encoded binary data.

Some possible solutions:

* Add the putXXX() and getXXX() methods for each type to the Message API
* Create a class for putting and getting binary data that takes a 
message, and puts and gets binary data

Message m;
BinaryStuffer bs(m);
bs.putShort(i);

* Add a MapMessage type, as in JavaJMS.

Jonathan

Gordon Sim wrote:
> Jonathan Robie wrote:
>> On the whole, I really like this. Comparing the example programs to 
>> the existing examples, I think it does simplify quite a bit.
>>
>> A few thoughts:
>>
>> 1. Streaming data into or out of messages
>>
>> I really want to be able to stream into or out of messages directly.
>>
>> Instead of:
>>
>>            message_data << "Message " << i;
>>            message.setData(message_data.str());
>>
>> I would like to be able to do something like:
>>
>>            message.getData() << "Message " << i;
>
> Yes, I can see that would be convenient.


---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:dev-subscribe@qpid.apache.org