On Thu, May 15, 2014 at 01:04:13PM -0400, Ernest Allen wrote:
> Does proton messenger support sending complex maps as the message body? That 
> is, maps whose values are other maps or lists and not just strings?
> 
> When I send a message and the body is encoded as qpid::proton::MAP, the map 
> values appear to have been converted to strings.
> 
> For example (in perl)
> 
> In the sender
> $msg->set_body({"foo" => 2, "bar" => [3]}, qpid::proton::MAP);
> 
> In the receiver when I dump the body, I'm getting
>  $VAR1 = \{
>             'bar' => 'ARRAY(0xa2aad0)',
>             'foo' => '2'
>           };
> 
> It appears that the array has been converted to the string 'ARRAY(0x...)'. 
> And the 2 is now a string '2'.
> I don't think this is just the way the receiver is dumping the message body 
> as I'm not able to convert the results to the expected type or variable.
> 
> When I send a perl HASH instead of an array as one of the values, it is 
> coming through as the string'HASH(0x....)'. 

This should now be fixed on trunk. I've updated the recv.pl example to
display the full body of received messages to verify that all values are
being passed.

Now, that being said, there's a caveat with Perl. Since there's no way
for Perl to determine what any scalar value is (beyond the class name
for blessed objects) everything has to be inserted into the data object
as a string. So, for example, if you put the following into the body of
a message in Perl:

  $msg->set_body({"fibonacci" => [1, 1, 2, 3, 5, 8, 13]});

then the receive will get:

  {"fibonacci" => ["1", "1", "2", "3", "5", "8", "13"]}

I'll continue to look for some way to improve this, but for now at least
the structure of complex hashes and arrays are preserved in Perl.

-- 
Darryl L. Pierce, Sr. Software Engineer @ Red Hat, Inc.
Delivering value year after year.
Red Hat ranks #1 in value among software vendors.
http://www.redhat.com/promo/vendor/

Attachment: pgpalvNfYs_43.pgp
Description: PGP signature

Reply via email to