diff options
| author | Gordon Sim <gsim@apache.org> | 2014-07-21 12:44:19 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2014-07-21 12:44:19 +0000 |
| commit | 99c81b97860d64b476a40090231d823996db82a6 (patch) | |
| tree | e516ab8557b3a04cc96250d241231d1431384c08 /qpid/cpp/src | |
| parent | 211a72d92881514ee10161ba56c8c62b1eb2b581 (diff) | |
| download | qpid-python-99c81b97860d64b476a40090231d823996db82a6.tar.gz | |
QPID-5908: merge annotations into properties, don't replace existing elements
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1612258 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
| -rw-r--r-- | qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp index 179297278f..14fc09505d 100644 --- a/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp +++ b/qpid/cpp/src/qpid/messaging/amqp/EncodedMessage.cpp @@ -117,6 +117,21 @@ void EncodedMessage::init(qpid::messaging::MessageImpl& impl) } void EncodedMessage::setNestAnnotationsOption(bool b) { nestAnnotations = b; } +namespace { +using qpid::types::Variant; +void merge(qpid::types::Variant::Map& map, const qpid::types::Variant::Map& additions) +{ + for (Variant::Map::const_iterator i = additions.begin(); i != additions.end(); ++i) + { + if (map.find(i->first) == map.end()) { + map[i->first] = i->second; + } else { + QPID_LOG(info, "Annotation " << i->first << " hidden by application property of the same name (consider using nest_annotations option?)"); + } + } +} +} + void EncodedMessage::populate(qpid::types::Variant::Map& map) const { try { @@ -156,7 +171,7 @@ void EncodedMessage::populate(qpid::types::Variant::Map& map) const if (nestAnnotations) { map["x-amqp-delivery-annotations"] = decoder.readMap(); } else { - decoder.readMap(map); + merge(map, decoder.readMap()); } } if (messageAnnotations) { @@ -164,7 +179,7 @@ void EncodedMessage::populate(qpid::types::Variant::Map& map) const if (nestAnnotations) { map["x-amqp-message-annotations"] = decoder.readMap(); } else { - decoder.readMap(map); + merge(map, decoder.readMap()); } } } catch (const qpid::Exception& e) { |
