[rabbitmq-discuss] Decoding header fields

Bernhard Mogens Ege bme at saseco.dk
Thu Aug 2 14:25:06 BST 2012


I already said I was looking to send other types but started with a string.
That is contains a number is of no importance here.
But I did not expect that the string object would be received as a byte[]
object. But if that is how RabbitMQ is designed, so be it. 
It just doesn't make sense to me.

I'll try sending other types to see if they arrive as intended (int as int,
double as double, etc.).

[testing time passes]

It does appear that at least the type double does get passed through
unharmed. Only strings are passed as byte[]. 

Is  this be because RabbitMQ doesn't know the encoding to use when receiving
a string? If so, that would make sense. 
Hmm looking at WireFormatting.cs, UTF8 is already assumed when converting a
string to byte[]. Why not assume UTF8 
when receiving the byte[] and return a string instead of a byte[] (offending
method: ReadLongstr)?
-- 
Bernhard

-----Original Message-----
From: Emile Joubert [mailto:emile at rabbitmq.com] 
Sent: 2. august 2012 15:06
To: bme at saseco.dk; Discussions about RabbitMQ
Subject: Re: [rabbitmq-discuss] Decoding header fields

Hi,

On 01/08/12 12:07, Bernhard Mogens Ege wrote:
> sendMessage("myroutingkey", new Dictionary<string, string> { { 
> "languageid", "1" } }, null);

If you only ever send strings values then you will only ever receive byte
array values (via the intermediate 'S'-prefixed table value). See
Wireformatting.WriteFieldValue() and ReadFieldValue(). The string "1" is
still a string and won't automatically be recognised as a number.

If the producer sends other types of values then the consumer will receive
other types of values.

-Emile



More information about the rabbitmq-discuss mailing list