qpid-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gordon Sim <g...@redhat.com>
Subject Re: QPid 0.28 amqp1.0 - sending map from java to c++ does not work
Date Mon, 21 Jul 2014 11:52:35 GMT
On 07/21/2014 12:28 PM, Andreas Welchlin wrote:
> No, I am not using getContentObject but the decode function:

Ok, that is the problem. You need to use getContentObject() for AMQP 1.0 
messages. You can use that for 0-10 also and it works regardless of the 
type of object sent (e.g. binary or utf will also be correctly retrieved).

The qpid::messaging::decode() functions only decode 0-10 typed data. In 
AMQP 1.0, rather than using a content-type header to indicate the type 
of the content, the AMQP type system itself is used. This meant we had 
to add something to the API to expose that information. The concept of 
content object was added which indicates the type through 
Variant::getType() but also presents a decoded representation.

> MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
> {
>      if (qpidMessage.getContentType() != "amqp/map")
>      {
>          // When Java Applications send an AMQP/MAP in amqp version 1.0,
> then the string is found
>          // in the properties.
>          qpid::types::Variant::Map properties =
> qpidMessage.getProperties();
>          if (properties["x-opt-jms-type"].asString() != "amqp/map")
>              THROW(UsrException, "wrong content type (!= amqp/map): " <<
> qpidMessage.getContentType());
>      }
>
>      qpid::types::Variant::Map map;
>      qpid::messaging::decode(qpidMessage, map);
>      mSystemMessageId.assign(map["SytemMsgId"].asString());
>      mContent = map["content"].asString();
> }

The above would be something like:

using namespace qpid::types;

MyMessage::MyMessage(const qpid::messaging::Message &qpidMessage)
{
     if (qpidMessage.getContentObject().getType() != VAR_MAP)
     {
         THROW(UsrException, "Message content was not a map!");
     }
     Variant::Map map = qpidMessage.getContentObject().asMap();
     mSystemMessageId.assign(map["SytemMsgId"].asString());
     mContent = map["content"].asString();
}

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@qpid.apache.org
For additional commands, e-mail: users-help@qpid.apache.org


Mime
View raw message