I want to transfer an image from a client to the server using RabbitMQ. However, from whatever I read, I understood that RabbitMQ can only transfer a stream of text. So how to transfer an image?
Asked
Active
Viewed 8,965 times
2
-
1Where did you read that you can only transfer a stream of text? That is false. You can transfer a stream of bytes; which is what an image is. – slim Sep 06 '17 at 10:08
-
1https://github.com/alanxz/rabbitmq-c/blob/master/examples/amqp_producer.c sends 256-byte messages consisting of byte values `0x00` to `0xFF` – slim Sep 06 '17 at 10:11
1 Answers
1
The amqp body is a buffer, you can send what you want.
In general, if you want to send a file, you have to read it and send the buffers.
You should send the file using more publish and not just one, then recreate the file on the consumer side.
You should avoid sending big buffer.

Gabriele Santomaggio
- 21,656
- 4
- 52
- 52
-
By default the RabbitMQ broker does not impose any limit on message payload sizes (though its possible to create one). That said, the sender, broker and receiver all must be able to hold the entire message in-memory. – alanxz Sep 07 '17 at 05:28
-
@alanxz yes, I just suggested having a fixed buffer. Images can be very large, and I saw more than one time problems related to big buffers in term of memory and sockets. Speaking about files it is always a good practice implement a sort of streaming. (In my opinion) especially if the clients are not in LAN. – Gabriele Santomaggio Sep 07 '17 at 08:41