Two questions about AMQP protocol's marshalling/unmarshalling

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Two questions about AMQP protocol's marshalling/unmarshalling

raocheng
While I am reading amqp0-9-1.pdf, I get two questions about  AMQP protocol's marshalling/unmarshalling: 

4.2.5.3 Strings: 
Short strings, stored as an 8-bit unsigned integer length followed by zero or more octets of data. Short strings can carry up to 255 octets of UTF-8 data, but may not contain binary zero octets.

=======
Question: What does "binary zero octets" mean ? Why can they not be contained in shortstr ?
=======

4.2.5.5 field Tables
... The name-value pairs are encoded as short string defining the name, and octet defining the values type and then the value itself.

=======
Question: By the definition, there should be an octet used for defining the values type. So where can we know the detailed definition for each value type (e.g, 1 --> octet, 2 -> short, 3-> long, 4 -> longlong, 5 -> shortstr, 6-> longstr, 7->table, ...) ? I can not find the corresponding definition in AMQP's documents(amqp0-9-1.xml, amqp0-9-1.pdf)
=======

Thanks in advance!

_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Two questions about AMQP protocol's marshalling/unmarshalling

Gordon Sim-2
On 10/01/2012 03:10 PM, raocheng wrote:

> While I am reading amqp0-9-1.pdf, I get two questions about  AMQP
> protocol's marshalling/unmarshalling:
>
> 4.2.5.3 Strings:
> Short strings, stored as an 8-bit unsigned integer length followed by
> zero or more octets of data. Short strings can carry up to 255 octets of
> UTF-8 data, but may not contain binary zero octets.
>
> =======
> Question: What does "binary zero octets" mean ?

It means the octet with value 0x00.

> Why can they not be
> contained in shortstr ?

I think it is so the values can be treated as C-strings (where the 0x00
or null character is the string terminator).

> =======
>
> 4.2.5.5 field Tables
> ... The name-value pairs are encoded as short string defining the name,
> and octet defining the values type and then the value itself.
>
> =======
> Question: By the definition, there should be an octet used for defining
> the values type. So where can we know the detailed definition for each
> value type (e.g, 1 --> octet, 2 -> short, 3-> long, 4 -> longlong, 5 ->
> shortstr, 6-> longstr, 7->table, ...) ? I can not find the corresponding
> definition in AMQP's documents(amqp0-9-1.xml, amqp0-9-1.pdf)

I agree it is not terribly obvious given the flow of the text, but look
at the protocol grammar in 4.2.1 section. The type codes are given
against the definition of 'field-value'.


_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Two questions about AMQP protocol's marshalling/unmarshalling

Simon MacMullen-2
On 01/10/12 17:35, Gordon Sim wrote:
> On 10/01/2012 03:10 PM, raocheng wrote:
>> Question: What does "binary zero octets" mean ?
>
> It means the octet with value 0x00.

...and just for extra clarity, the only way to end up with a byte 0x00
in your string is to encode the Unicode NULL character U+0000. Actually
I don't think RabbitMQ will stop you doing this, but it's probably a
good way to increase the amount of confusion in your life.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Two questions about AMQP protocol's marshalling/unmarshalling

Simon MacMullen-2
On 02/10/12 10:44, raocheng wrote:
> How about my second question? Does anybody know where can we find the
> definition for each value type (e.g, 0-> bit,  1 --> octet, 2 -> short,
> 3-> long, 4 -> longlong, 5 -> shortstr, 6-> longstr, 7->table, ...)  ?

Gordon already answered it - see section 4.2.1 under "field-value".

However.

The 0-9-1 spec changed at the last minute in this regard for unclear
reasons. So RabbitMQ does not actually implement what's in the spec - I
suspect no-one does. See

http://www.rabbitmq.com/amqp-0-9-1-errata.html#section_3

for what we actually implement.

Cheers, Simon

--
Simon MacMullen
RabbitMQ, VMware
_______________________________________________
rabbitmq-discuss mailing list
[hidden email]
https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss