Jesse Hulsizer created QPID-8598:
------------------------------------
Summary: qpid-cpp broker encodes compound types in AMQP 1.0 message
Key: QPID-8598
URL: https://issues.apache.org/jira/browse/QPID-8598
Project: Qpid
Issue Type: Bug
Components: C++ Broker
Affects Versions: qpid-cpp-1.39.0
Environment: RHEL8, qpid-proton 0.36.0, qpid-cpp 1.39.0
Reporter: Jesse Hulsizer
Attachments: reproducer.cpp
The AMQP 1.0 standard states that the "application properties" of a message can
only contain simple types. However, the AMQP 0-10 standard has no such
limitations on the equivalent "application headers" of a message. It appears
that when the qpid-cpp broker encodes a message into the AMQP 1.0 format, it
does not adhere to this limitation, and will encode the compound type into the
application properties map.
When attempting to use qpid-proton to read these messages from the broker, the
qpid-proton library will throw a proton::error "expected scalar, found map"
when attempting to decode the properties.
It should be noted that when enabling the amqp1.0 protocol with the
qpid-cpp-client libraries, that the library will not allow the message to be
sent, and will strip the compound types from the message prior to sending.
I've attached a reproducer that is adapted from the hello_world examples of
qpid-cpp and qpid-proton. This reproducer does the following:
1. Using AMQP 0-10, creates a message with application headers that contain a
nested map, then sends the message to the broker and receives it.
2. Using the qpid-cpp-client library with AMQP 1.0, creates a message with
application headers that contain a nested map, then sends the message to the
broker and receives it. You can see in the output that the qpid-cpp-client
libray strips the disallowed types from the application headers.
3. Opens a qpid-proton receiver to the broker, then using the qpid-cpp-client
in AMQP 0-10 mode, sends a message to the broker. It further shows what can and
cannot be done with the message in qpid-proton (printing the receiver message,
extracting the properties into a std::map, and attempting to perform a copy of
the message).
I'm not sure what the correct behavior is for the broker when attempting to
encode a message with the nested application map, but given the qpid-cpp-client
library behavior when encountering a similar message, should the broker strip
the nested maps from the library to ensure that the sent message meets the AMQP
1.0 spec?
Output of the reproducer:
[builder@buildhost QPID-CPP-Application-Property-Map $ ] g++ -lqpidmessaging
-lqpidtypes -lqpid-proton-cpp -lpthread reproducer.cpp -o reproducer &&
./reproducer
Send and receive with qpid-cpp-client in AMQP 0-10 mode
Hello world!
{map:{baz:42, foo:bar}, x-amqp-0-10.routing-key:}
Send and receive with qpid-cpp-client in AMQP 0-10 mode
2022-08-26 23:47:25 [Messaging] warning Skipping nested list and map; not
allowed in application properties.
2022-08-26 23:47:25 [Messaging] warning Skipping nested list and map; not
allowed in application properties.
2022-08-26 23:47:25 [Messaging] warning Skipping nested list and map; not
allowed in application properties.
Hello world!
{x-amqp-first-acquirer:True}
Send with qpid-cpp-client in AMQP 0-10 mode and receive with qpid-proton
Printing received message
Message{address="amq.topic", priority=0, first_acquirer=1, user_id="",
subject="", content_type="text/plain", inferred=1, properties={"map"={"baz"=42,
"foo"=b"bar"}}, body=b"Hello world!"}
Extracting properties
props[map]={"baz"=42, "foo"=b"bar"}
Printing copied message
Error! expected scalar, found map
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]