| <div class="wiki-content maincontent"><p><strong>deprecated</strong></p> |
| |
| <structured-macro ac:macro-id="88cf66c6-a3ba-4c16-afbf-0ef5c8fed79a" ac:name="warning" ac:schema-version="1"><rich-text-body> |
| <p>This feature is deprecated, and end users is encouraged to <strong>not</strong> use it. This feature will be removed in a later ActiveMQ release.</p></rich-text-body></structured-macro> |
| |
| <p>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.</p> |
| |
| <p>To solve this problem ActiveMQ supports regular <a shape="rect" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html">InputStream</a> and <a shape="rect" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStream.html">OutputStream</a> abstractions which work with regular JMS producers and consumers.</p> |
| |
| <p>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 <emoticon ac:name="smile"></emoticon> while keeping a low memory overhead.</p> |
| |
| <structured-macro ac:macro-id="3849c84e-3152-47d0-8075-de533a4015af" ac:name="info" ac:schema-version="1"><parameter ac:name="title">For Users of 4.2</parameter><rich-text-body> |
| <p>If you are using 4.2 onwards of ActiveMQ we highly recommend you try out <link><page ri:content-title="Blob Messages"></page></link> 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.</p></rich-text-body></structured-macro> |
| |
| <h3>Using JMS Streams</h3> |
| |
| <p>To use the streams just create an input or output stream depending on if you are reading or writing using the <a shape="rect" href="http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQConnection.html#createInputStream(javax.jms.Destination)">connection.createInputStream()</a> or<br clear="none"> |
| <a shape="rect" href="http://incubator.apache.org/activemq/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQConnection.html#createOutputStream(javax.jms.Destination)">connection.createOutputStream()</a> methods.</p> |
| |
| <p>e.g.</p> |
| |
| <structured-macro ac:macro-id="0a3d4912-0a8c-4072-8031-2972c28d04ab" ac:name="code" ac:schema-version="1"><plain-text-body> |
| ActiveMQConnection connection = ...; |
| Destination destination = new ActiveMQQueue("FOO.BAR"); |
| |
| OutputStream out = connection.createOutputStream(destination); |
| |
| // write the file to out |
| out.close(); |
| </plain-text-body></structured-macro> |
| |
| <p>Or to consume a large message</p> |
| |
| |
| <structured-macro ac:macro-id="e351d85f-34c6-4d59-b017-d9489e64f04f" ac:name="code" ac:schema-version="1"><plain-text-body> |
| ActiveMQConnection connection = ...; |
| Destination destination = new ActiveMQQueue("FOO.BAR"); |
| |
| InputStream in = connection.createInputStream(destination) |
| |
| // read the stream... |
| in.close(); |
| </plain-text-body></structured-macro> |
| |
| <p>There are overloaded createInputStream/createOutputStream methods which support additional paramateres to be passed.</p> |
| |
| <p>For further reference see the javadoc.</p> |
| |
| <ul><li><a shape="rect" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQInputStream.html">ActiveMQInputStream </a></li><li><a shape="rect" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQOutputStream.html">ActiveMQOutputStream </a></li></ul> |
| |
| |
| |
| <p><em>Note:</em><br clear="none"> |
| The counterpart classes in AMQ 3.x are :</p> |
| <ul><li>JMSInputStream</li><li>JMSOutputStream</li></ul> |
| </div> |
| |