Chapter 21. Large Messages

HornetQ supports sending and receiving of large messages, even when the client and server are running with limited memory. The only realistic limit to the size of a message that can be sent or consumed is the amount of disk space you have available.
To send a large message, the user can set an InputStream on a message body. When that message is sent, HornetQ will read the InputStream. For example, a FileInputStream could be used to send a large message from a large file on disk.
As the InputStream is read, the data is sent to the server as a stream of fragments. The server persists these fragments to disk as it receives them. When the time comes to deliver them to a consumer they are read back off the disk, also in fragments, and re-transmitted. When the consumer receives a large message it initially receives just the message with an empty body. It can then set an OutputStream on the message to stream the large message body to a file on disk or elsewhere. At no time is the entire message body stored fully in memory, either on the client or the server.

21.1. Configuring the server

Large messages are stored on a disk directory on the server side, as configured in <JBOSS_HOME>/jboss-as/server/<PROFILE>/deploy/hornetq/hornetq-configuration.xml.
The configuration property large-messages-directory specifies where large messages are stored.
<configuration xmlns="urn:hornetq"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="urn:hornetq /schema/hornetq-configuration.xsd">

...

   <large-messages-directory>${jboss.server.data.dir}/${hornetq.data.dir:hornetq}/largemessages</large-messages-directory>

...

</configuration>
By default the large message directory is data/large-messages.
For the best performance it is recommended that the large messages directory is stored on a different physical volume to the message journal or paging directory.