Size and types of RabbitMQ messages

  • What messages can be stored in RabbitMQ queues? Just strings? Or can I choose which type I want to store: int, binary, string, etc.?
  • What is the maximum size of a single message?
  • How many queues or exchanges can be created? Or does it depend on the server capacity?
+92
queue rabbitmq message-queue amqp
Aug 21 '13 at 9:35 on
source share
3 answers
  • Theoretically, everything could be saved / sent as a message. You actually do not want to store anything in the queues. The system works most efficiently if the queues remain empty most of the time. You can send anything you want to the queue with two preconditions:

    • The thing you send can be converted to and from byte
    • The consumer knows exactly what he gets and how to convert it to the source object.

    Strings are pretty simple, they have a built-in method for converting to and from bytes. If you know this is a string, you know how to return it. It is best to use a markup string such as XML, JSON, or YML. This way you can convert objects to strings and back to the original objects; they work in all programming languages, so your consumer can be written in another language for your producer if he knows how to understand the object. I am working in Java. I want to send complex messages with sub-objects in fields. I use my own message object. The message object has two additional methods, toBytes and fromBytes , which are converted to and from a byte stream. I use routing keys that leave no doubt about what type of message a consumer receives. Post is Serializable. This works great, but is limited since I can only use it with other Java programs.

  • The message size is limited by the memory on the server, and if it is permanent, then there is also free space on the hard disk. You probably do not want to send too large messages; it would be better to send a link to a file or database.

    You can also see their performance indicators: http://www.rabbitmq.com/blog/2012/04/17/rabbitmq-performance-measurements-part-1/ http://www.rabbitmq.com/blog/2012 / 04/25 / rabbitmq-performance-measurements-part-2 /

  • The queues are pretty easy, you will most likely be limited by the number of connections. This will probably depend on the server. Here is some information on a related issue: http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/2009-February/003042.html

+108
Aug 21 '13 at 10:38
source share

The maximum message size in RabbitMQ was 2 GB up to version 3.7:

 %% Trying to send a term across a cluster larger than 2^31 bytes will %% cause the VM to exit with "Absurdly large distribution output data %% buffer". So we limit the max message size to 2^31 - 10^6 bytes (1MB %% to allow plenty of leeway for the #basic_message{} and #content{} %% wrapping the message body). -define(MAX_MSG_SIZE, 2147383648). 

Link: https://github.com/rabbitmq/rabbitmq-common/blob/v3.7.13/include/rabbit.hrl#L279

Now it is 512 MB since version 3.8:

 %% Max message size is hard limited to 512 MiB. %% If user configures a greater rabbit.max_message_size, %% this value is used instead. -define(MAX_MSG_SIZE, 536870912). 

Link: https://github.com/rabbitmq/rabbitmq-common/blob/master/include/rabbit.hrl#L238

+6
Mar 08 '19 at 10:32
source share
  • See robthewolf answer .

  • The maximum message size is 2 GB, but tuning the performance of messages of this size is inefficient. Maximum message size

  • There is no hard limit set by RabbitMQ Server Software on the number of queues, however, the hardware on which the server runs can greatly affect this limit.

3a. By default, the server has no limit on the length of the queue. However, you can restrict this to server-side policy (configuration) or client-side policy. Maximum Queue Length

Additional information and links to the message

+4
Nov 02 '17 at 18:29
source share



All Articles