What format does RabbitMQ use to convert data into byte array

2,700 views
Skip to first unread message

Graham Cleary

unread,
Oct 29, 2018, 11:30:09 AM10/29/18
to rabbitmq-users
Hi,

Can someone explain what happens here:

  1. Pass message of "boo" into the queue
         _publisher.Publish(Encoding.UTF8.GetBytes("boo"));
         byte array is 34,98,111,111,34
  2. At the consumer end, the byte array is now
         34,89,109,57,118,34 which is "Ym9v" using an ASCII table.

Can someone explain to me what encoding RabbitMQ uses?? I'm getting weird results.

Thanks,
Graham.

Luke Bakken

unread,
Oct 29, 2018, 11:38:40 AM10/29/18
to rabbitmq-users
Hi Graham,

RabbitMQ doesn't do anything with the message payload, so the issue must be in either the publisher or consumer. Based on the code you have shown, you're using the .NET client for the publisher. What is consuming data? Can you provide a concise set of code to reproduce this?

Thanks,
Luke

Graham Cleary

unread,
Oct 29, 2018, 11:47:20 AM10/29/18
to rabbitmq-users

Hi Luke,


You are correct I am using the RabbitMQ.Client using .NET Core.


Capture.PNG


Basically the code is as follows:

public Task Publish(byte[] bytes)
{
var connection = _factory.CreateConnection();
var channel = connection.CreateModel();
var helper = new RabbitMQHelper(channel, _config);
helper.SetupPublisher();

helper.PushMessageIntoQueue(bytes, _config.SavedRoutingKey);
return Task.CompletedTask;
}


Luke Bakken

unread,
Oct 29, 2018, 1:27:21 PM10/29/18
to rabbitmq-users
Hi Graham,

Thanks for providing that code snippet, but it's not helpful in diagnosing your issue. What would be helpful is code that I can compile and run (both producer and consumer) that demonstrates the issue. For instance, here is a git repo I put together for this issue that demonstrates sending and receiving a message. When run, it works correctly:


If you could do the same that would be great.

Thanks,
Luke

On Monday, October 29, 2018 at 8:47:20 AM UTC-7, Graham Cleary wrote:

Hi Luke,


You are correct I am using the RabbitMQ.Client using .NET Core.


Maciej Gałkowski

unread,
Oct 30, 2018, 10:47:26 AM10/30/18
to rabbitmq-users
Hi Graham, 
Ym9v is "boo" encoded in base64. 
Something somewhere is taking the input bytes and converts it to base64 string. 
I have no clue about the .net core client, but this doesn't look like a RabbitMQ issue to me. 
From my side, we have sent binary data over the rabbitMQ messages without any problem. 
I would suspect the sender of the message. 

You could use the management plugin to preview the message that is pending in the RabbitMQ queue. Please note that the returned string is a base64 representation of the message bytes if the management plugin detects binary data.

Regards, 
Maciej

Michael Klishin

unread,
Oct 30, 2018, 11:01:49 AM10/30/18
to rabbitm...@googlegroups.com
RabbitMQ [messaging protocol] clients do not convert user inputs to base64.

HTTP API clients don't do that beyond the extent that HTTP requires it (at least I cannot think of the contrary).

Wireshark [1] is a great tool to apply here.


--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages