Question: I plan on storing stacktraces in the RabbitMQ message header. Do message headers have a size limit?

Answer: 
RabbitMQ is using by default the AMQP version 0.9.1. According to the [AMQP protocol specification](https://www.rabbitmq.com/resources/specs/amqp0-9-1.pdf) at page 31, a `field-table` can contains 4 billions entries:

> 
> long-uint = 4\*OCTET
> 
> 
> field-table = long-uint \*field-value-pair
> 
> 
> 

A `long-string` entry can have a length up to 4 billions octet:

> 
> long-string = long-uint \*OCTET ; length + content
> 
> 
> 

An AMQP message is split in 3 parts, header, properties, message. In the properties part you could put application-specific information. So the properties may contain your stacktrace.

By the way, headers and properties must be keept as small as possible because there is [performance penalty](https://groups.google.com/forum/#!topic/rabbitmq-users/JJ436bSC3s0)
> 
> The answers so far seem to indicate that it would be no problem to cram a stacktrace in a header.
> 
> 
> 

As John insinuates in his answer previously, some changes were made a couple of years a go that will cause an `IllegalArgumentException` to be thrown when the header size exceeds `frame_max` (by default this is indeed 128kB).

[(The source code I'm referring to can be found here!)](https://github.com/rabbitmq/rabbitmq-java-client/blob/283902d3ed7e42098b60cbbf95154aa93a741dbd/src/main/java/com/rabbitmq/client/impl/AMQCommand.java#L113)

As a (fun) side note, this was done to prevent an issue whereby messages that had single huge header that exceeded max frame size would result in the client creating and transmitting the huge header frame to server and, as a result, the server shuts the connection down with `frame_too_large` error and that breaks all open channels!

In order to include a stacktrace in a header, you *could* increase the header size, or set it to `0` for 'unlimited', but you should be aware that this isn't particularly advisable in most situations (larger values may improve throughput while smaller values may improve latency).