Large Message Streaming Using the JMS

WARNING - TOPIC NOT WRITTEN - TOPIC ID: 669

This topic has not yet been written. The content below is from the topic description.
23.3.2. Streaming over JMS When using JMS, HornetQ maps the streaming methods on the core API (see Table 23.1, “org.hornetq.api.core.client.ClientMessage API�) by setting object properties . You can use the method Message.setObjectProperty to set the input and output streams. The InputStream can be defined through the JMS Object Property JMS_HQ_InputStream on messages being sent: BytesMessage message = session.createBytesMessage(); FileInputStream fileInputStream = new FileInputStream(fileInput); BufferedInputStream bufferedInput = new BufferedInputStream(fileInputStream); message.setObjectProperty("JMS_HQ_InputStream", bufferedInput); someProducer.send(message); The OutputStream can be set through the JMS Object Property JMS_HQ_SaveStream on messages being received in a blocking way. BytesMessage messageReceived = (BytesMessage)messageConsumer.receive(120000); File outputFile = new File("huge_message_received.dat"); FileOutputStream fileOutputStream = new FileOutputStream(outputFile); BufferedOutputStream bufferedOutput = new BufferedOutputStream(fileOutputStream); // This will block until the entire content is saved on disk messageReceived.setObjectProperty("JMS_HQ_SaveStream", bufferedOutput); Setting the OutputStream could also be done in a non blocking way using the property JMS_HQ_OutputStream. // This won't wait the stream to finish. You need to keep the consumer active. messageReceived.setObjectProperty("JMS_HQ_OutputStream", bufferedOutput); Note When using JMS, Streaming large messages are only supported on StreamMessage and BytesMessage.