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: [email protected]
For additional commands, e-mail: [email protected]