JMS Streams

Features > Message Features > JMS Streams


This feature is deprecated, and end users is encouraged to not use it. This feature will be removed in a later ActiveMQ Classic release.

Sometimes you need to send truly massive files (many Gb) around the network in a reliable manner. The JMS API expects JMS clients to be able to keep a message in memory at one time, so sending > 1Gb messages around ends up using way too much RAM on the client side.

To solve this problem ActiveMQ Classic supports regular InputStream and OutputStream abstractions which work with regular JMS producers and consumers.

This allows you to use the familar streams from Java to send or receive messages of any size at all (providing your file system can handle them while keeping a low memory overhead.

For Users of 4.2

If you are using 4.2 onwards of ActiveMQ Classic we highly recommend you try out Blob Messages which offers a more flexible mechanism for dealing wtih massive files and fully supports out-of-band transfer using HTTP/FTP as well as allowing external resources to be sent around the JMS network.

Using JMS Streams

To use the streams just create an input or output stream depending on if you are reading or writing using the connection.createInputStream() or
connection.createOutputStream() methods.


ActiveMQConnection connection = ...;
Destination destination = new ActiveMQQueue("FOO.BAR");

OutputStream out = connection.createOutputStream(destination);

// write the file to out

Or to consume a large message

ActiveMQConnection connection = ...;
Destination destination = new ActiveMQQueue("FOO.BAR");

InputStream in = connection.createInputStream(destination)

// read the stream...

There are overloaded createInputStream/createOutputStream methods which support additional paramateres to be passed.

For further reference see the javadoc.

The counterpart classes in AMQ 3.x are :

  • JMSInputStream
  • JMSOutputStream

Apache, ActiveMQ, Apache ActiveMQ, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright © 2024, The Apache Software Foundation. Licensed under Apache License 2.0.