qpid-proton mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Fraser Adams <fraser.ad...@blueyonder.co.uk>
Subject Re: Quotes in the message body
Date Fri, 28 Mar 2014 16:03:03 GMT
On 28/03/14 15:20, serega wrote:
> Thanks for the explanation. Yes, I used recv client.
> I had to also call pn_data_next(body) to make it work, so it looks like so
> --------------------------------------------------------------------------
> pn_data_t *body = pn_message_body(message);
> pn_data_next(body);
> pn_bytes_t bytes =  pn_data_get_string(body);
> --------------------------------------------------------------------------
Ahh sorry I missed the  pn_data_next stuff. TBH I'm as much of a novice 
to this API as you :-/

Funnily enough I'm working my way through it by looking at the python 
binding in <proton>/proton-c/bindings/python/proton.py I know it might 
sound a bit obtuse, but python has a fairly natural OO API and uses 
introspection, so if you are looking for how to encode and decode things 
looking at the python stuff shows most of what you need, unfortunately I 
missed a "cheeky post decode" call when I first replied ......

   def _post_decode(self):
     inst = Data(pn_message_instructions(self._msg))
     ann = Data(pn_message_annotations(self._msg))
     props = Data(pn_message_properties(self._msg))
     body = Data(pn_message_body(self._msg))

     if inst.next():
       self.instructions = inst.get_object()
       self.instructions = None
     if ann.next():
       self.annotations = ann.get_object()
       self.annotations = None
     if props.next():
       self.properties = props.get_object()
       self.properties = None
     if body.next():
       self.body = body.get_object()
       self.body = None

I can see now that there's a call to pn_data_next (wrapped by the 
body.next() call).

By the way judging from this, for safety it looks like you should also 
be checking the return value of pn_data_next and only calling your 
pn_data_get_string if the return value is true.

> The Qpid Proton needs more documentation and/or example code. The
> messenger.h is very well documented, but I couldn't find any documentation
> on how to read and write data (properties, body) from and to a message.
I agree, I actually posted on a related topic on the qpid users mailing 
list - the good news is that improved API documentation should be 
happening fairly soon.


View raw message