Thanks a ton Rafael!
The key was adding pn_data_next(properties) to get the cursor on the map.
The tip about using pn_data_dump was also very helpful. What I get when I dump
the properties of my message is below. The type indicates the data type as
defined by the pn_type_t enum. Is that correct?
Node 1: prev=0, next=0, parent=0, down=2, children=6, type=24 (map)
Node 2: prev=0, next=3, parent=1, down=0, children=0, type=19 ("First")
Node 3: prev=2, next=4, parent=1, down=0, children=0, type=7 (1)
Node 4: prev=3, next=5, parent=1, down=0, children=0, type=19 ("Second")
Node 5: prev=4, next=6, parent=1, down=0, children=0, type=7 (2)
Node 6: prev=5, next=7, parent=1, down=0, children=0, type=19 ("Third")
Node 7: prev=6, next=0, parent=1, down=0, children=0, type=7 (3)
From: Rafael Schloming [mailto:r...@alum.mit.edu]
Sent: Monday, March 25, 2013 9:14 AM
Subject: Re: Getting AMQP message properties though Proton-C
On Fri, Mar 22, 2013 at 3:01 PM, Arun Dsouza <ardso...@microsoft.com> wrote:
> I would like to know the correct way to access AMQP message properties
> through Proton-C. If this the not the right mailing list for Proton-C
> usage queries, I apologize and please direct me to the mailing list.
This is a fine place. Sorry for the delay in replying. I've been laid up for a
few days recovering from a medical procedure last week.
> The scenario I have is an interop scenario where I send messages to a
> Windows Azure Service Bus queue using the Service Bus .NET API, and
> I receive from the queue using the Linux version of the Proton-C
> client ( Release 0.4 ) While sending messages I set some properties on
> AMQP message, and I want to get those properties from the Proton-C
> receiver. The properties are simple key value pairs where the Key is a
> string and the Value is an Int.
> I would like to know how do I go about getting the properties from the
> received pn_message_t
> Here's what I am currently doing. But the mapsize is always 0.
> pn_messenger_get(messenger, message);
> pn_data_t *properties = pn_message_properties(message);
> size_t mapsize = pn_data_get_map(properties);
> int x=0;
> for(x =0; x< mapsize/2; x++ )
> printf("Property: %d\n",pn_data_get_int(properties));
For one thing you should actually check that the type of the value you're
trying to get is a map, e.g. print out pn_data_type(properties) and see if that
is actually a map. If the data object's cursor happens to be pointing to
something that is not a map, then get_map will always return 0.
In this case my guess is that you need to do a pn_data_next(properties); in
order to position the cursor on the map prior to accessing it, however you can
always do a pn_data_dump(properties); to see exactly what is going on.
If you post the output from that I can provide a little more help. Here's my
pn_data_t *properties = pn_message_properties(message);
// advance the cursor to the first object
// assert that it is the properties map
assert(pn_data_type(properties) == PN_MAP);
size_t mapsize = pn_data_get_map(properties);
// enter the properties map
for(x =0; x< mapsize/2; x++ )
// exit the properties map