You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by Daniele Palaia <da...@gmail.com> on 2024/12/11 14:49:10 UTC
Qpid-proton python: Encoding of an empty message body
Hello,
I'm Daniele from the RabbitMQ team.
We are working on a RabbitMQ amqp 1.0 client for Python specifically
adapted for RabbitMQ and we are using the qpid-proton python library as a
wrapping library to Send and Receive messages.
For some operations we need to send a Message with an empty body but it
looks like something is not working properly
I tried in the following way:
amq_message = Message(
body=Data.NULL,
)
But the encoded message that I get is:
[0, 83, 112, 69, 0, 83, 115, 69, 0, 83, 119, 85, 1]
From how is explained here:
https://github.com/Azure/go-amqp/issues/332
The encoded values for the first 4 bytes should be:
[0] = {byte} 0[1] = {byte} 83 // TypeCodeSmallUlong[2] = {byte} 119 //
TypeCodeAMQPValue [3] = {byte} 64 // TypeCodeNull
as from oasis documentation:
The problem statement is summarised as follows:
"The client should be able to send a body consisting of a single
amqp-value section
(https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-amqp-value)
which in turn consists of the AMQP null value
(https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-null)"
------------------------------
Is there something I'm missing?
Thanks a lot for your help,
Daniele Palaia
Re: Qpid-proton python: Encoding of an empty message body
Posted by Andrew Stitcher <as...@redhat.com.INVALID>.
I did not see this when it was raised (usually questions like this go to
the user list - the dev list is mostly automated emails for the developers
from various systems.
There is a misunderstanding in the use of Data.NULL - this is just a
constant which is used to indicate the type of a value in a Data structure
(the type discriminator). It is actually the value 1 so
Message(boby=Data.NULL) is asking to create a message with body of value 1.
This is indeed what it has done!
If you want to explicitly create a message with an empty body then this
would be Message(body=None). However in this case Proton knows that an
empty body does not need to be represented in the bytes in the message and
so the section that represents the body will actually be omitted. which
will give you as message something like [0, 83, 112, 69, 0, 83, 115, 69].
The 2 sections that are there are for message properties and message
annotations, I think, which the Proton does emit in this case there are
just empty lists though.
I'm not sure if you can force a body section with a null value.
Sorry I didn't see this to reply earlier.
Andrew
On Wed, Dec 11, 2024 at 10:00 AM Daniele Palaia <da...@gmail.com>
wrote:
> Hello,
>
> I'm Daniele from the RabbitMQ team.
> We are working on a RabbitMQ amqp 1.0 client for Python specifically
> adapted for RabbitMQ and we are using the qpid-proton python library as a
> wrapping library to Send and Receive messages.
>
> For some operations we need to send a Message with an empty body but it
> looks like something is not working properly
>
> I tried in the following way:
>
> amq_message = Message(
> body=Data.NULL,
> )
>
>
> But the encoded message that I get is:
>
> [0, 83, 112, 69, 0, 83, 115, 69, 0, 83, 119, 85, 1]
>
> From how is explained here:
>
> https://github.com/Azure/go-amqp/issues/332
>
> The encoded values for the first 4 bytes should be:
>
> [0] = {byte} 0[1] = {byte} 83 // TypeCodeSmallUlong[2] = {byte} 119 //
> TypeCodeAMQPValue [3] = {byte} 64 // TypeCodeNull
>
>
> as from oasis documentation:
>
> The problem statement is summarised as follows:
> "The client should be able to send a body consisting of a single
> amqp-value section
> (
> https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-amqp-value
> )
> which in turn consists of the AMQP null value
> (
> https://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-types-v1.0-os.html#type-null
> )"
> ------------------------------
>
>
> Is there something I'm missing?
>
> Thanks a lot for your help,
> Daniele Palaia
>