|
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 supports regular InputStream 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
Using JMS StreamsTo use the streams just create an input or output stream depending on if you are reading or writing using the connection.createInputStream() e.g. ActiveMQConnection connection = ...; Destination destination = new ActiveMQQueue("FOO.BAR"); OutputStream out = connection.createOutputStream(destination); // write the file to out out.close(); Or to consume a large message ActiveMQConnection connection = ...; Destination destination = new ActiveMQQueue("FOO.BAR"); InputStream in = connection.createInputStream(destination) // read the stream... in.close(); There are overloaded createInputStream/createOutputStream methods which support additional paramateres to be passed. For further reference see the javadoc. Note:
|