Skip to content

How to send messages over 8kb

Problem

You need to send messages greater than 8kb in size.

Solution

Term buffer length directly impacts the maximum message length. Setting a larger term buffer length will allow larger messages to be sent, up to 16MB.

Discussion

The formula for determining the maximum message length from the term buffer length is: min(16MB, Term Buffer Length / 8). You can increase the term buffer length by setting the default Term Buffer Lengths with the system property aeron.term.buffer.length or aeron.ipc.term.buffer.length. These can also be set on the Media Driver context using publicationTermBufferLength and ipcTermBufferLength.

If you require individual sizing of each Aeron publication, you can override the default value by specifying a term-length within the Aeron channel description, for example:

  • 128kb term length for an IPC channel: aeron:ipc?term-length=128k to support messages up to 16kb
  • 2MB term length for a UDP channel: aeron:udp?endpoint=192.168.0.1:12345|term-length=2m to support messages up to 256kb

Notes:

  • the term length value must be a power of 2. If not, you will get an exception: IllegalStateException : Term length not a power of 2
  • tryClaim will not support anything beyond maxPayloadLength (the default is 1376 bytes).
  • term buffer length cannot exceed 1,073,741,824 bytes.
  • You can use either fully defined values, like 65536 or you can use k or m to refer to kilobytes or megabytes respectively.
  • Aeron will not reconstruct fragmented messages automatically. See How to read fragmented messages

See Also