| <div class="wiki-content maincontent"><p><strong>deprecated</strong></p> |
| |
| <div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-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></div></div> |
| |
| <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" class="external-link" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStream.html" rel="nofollow">InputStream</a> and <a shape="rect" class="external-link" href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStream.html" rel="nofollow">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 <img class="emoticon emoticon-smile" src="https://cwiki.apache.org/confluence/s/en_GB/5997/6f42626d00e36f53fe51440403446ca61552e2a2.1/_/images/icons/emoticons/smile.png" data-emoticon-name="smile" alt="(smile)"> while keeping a low memory overhead.</p> |
| |
| <div class="confluence-information-macro confluence-information-macro-information"><p class="title">For Users of 4.2</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"> |
| <p>If you are using 4.2 onwards of ActiveMQ we highly recommend you try out <a shape="rect" href="blob-messages.html">Blob Messages</a> 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></div></div> |
| |
| <h3 id="JMSStreams-UsingJMSStreams">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" class="external-link" 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" class="external-link" 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> |
| |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> |
| ActiveMQConnection connection = ...; |
| Destination destination = new ActiveMQQueue("FOO.BAR"); |
| |
| OutputStream out = connection.createOutputStream(destination); |
| |
| // write the file to out |
| out.close(); |
| </pre> |
| </div></div> |
| |
| <p>Or to consume a large message</p> |
| |
| |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> |
| ActiveMQConnection connection = ...; |
| Destination destination = new ActiveMQQueue("FOO.BAR"); |
| |
| InputStream in = connection.createInputStream(destination) |
| |
| // read the stream... |
| in.close(); |
| </pre> |
| </div></div> |
| |
| <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" class="external-link" href="http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/ActiveMQInputStream.html">ActiveMQInputStream </a></li><li><a shape="rect" class="external-link" 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> |
| |