[rabbitmq-discuss] binary data corrupts when transferring on Rabbitmq

Matthias Radestock matthias at rabbitmq.com
Mon Dec 17 08:08:36 GMT 2012


On 17/12/12 05:49, saurabh256 wrote:
> I am new to RabbitMQ and tried to transfer a word document but seems when
> recieving or sending something happened during encoding or character set and
> output file gets corrupted.

This has nothing to do with rabbit. I suggest you first try to make the 
encoding and decoding work w/o involving RabbitMQ. E.g. take the 
fileContents var from your producer and feed it into the consumer in 
place of delivery.getBody().

FWIW, the problem is that you are reading the file as a byte stream but 
writing it as an object stream.

It shouldn't be hard to find examples on the internet for how to 
read/write files into/from a byte array. Worst case ask for help in some 
Java forums or stackoverflow.

Or take a peek at the File{Producer,Consumer}.java example code that 
ships with the java client.

Regards,

Matthias.



More information about the rabbitmq-discuss mailing list