이 콘텐츠는 선택한 언어로 제공되지 않습니다.

21.3. Streaming large messages


HornetQ supports setting the body of messages using input and output streams (java.lang.io).
These streams are then used directly for sending (input streams) and receiving (output streams) messages.
When receiving messages there are two ways to deal with the output stream; you may choose to block while the output stream is recovered using the method ClientMessage.saveOutputStream or alternatively using the method ClientMessage.setOutputstream which will asynchronously write the message to the stream. If you choose the latter the consumer must be kept alive until the message has been fully received.
You can use any kind of stream you like. The most common use case is to send files stored on your disk, but you could also send things such as:
  • JDBC Blobs
  • SocketInputStream
  • Things recovered from HTTPRequests, and so on.
Anything that implements java.io.InputStream for sending messages, or java.io.OutputStream for receiving them can be used.

21.3.1. Streaming over Core API

The following table shows a list of methods available at ClientMessage which are also available through JMS by the use of object properties.
Expand
Table 21.1. org.hornetq.api.core.client.ClientMessage API
Name Description JMS Equivalent Property
setBodyInputStream (InputStream) Set the InputStream used to read a message body when sending it. JMS_HQ_InputStream
setOutputStream (OutputStream) Set the OutputStream that will receive the body of a message. This method does not block. JMS_HQ_OutputStream
saveToOutputStream (OutputStream) Save the body of the message to the OutputStream. It will block until the entire content is transferred to the OutputStream. JMS_HQ_SaveStream
To set the output stream when receiving a core message:
...
ClientMessage msg = consumer.receive(...);

// This will block here until the stream was transferred
msg.saveToOutputStream(someOutputStream); 

ClientMessage msg2 = consumer.receive(...);

// This will not wait the transfer to finish
msg.setOutputStream(someOtherOutputStream); 
...
Copy to Clipboard Toggle word wrap
Set the input stream when sending a core message:
...
ClientMessage msg = session.createMessage();
msg.setInputStream(dataInputStream);
...
Copy to Clipboard Toggle word wrap
맨 위로 이동
Red Hat logoGithubredditYoutubeTwitter

자세한 정보

평가판, 구매 및 판매

커뮤니티

Red Hat 문서 정보

Red Hat을 사용하는 고객은 신뢰할 수 있는 콘텐츠가 포함된 제품과 서비스를 통해 혁신하고 목표를 달성할 수 있습니다. 최신 업데이트를 확인하세요.

보다 포괄적 수용을 위한 오픈 소스 용어 교체

Red Hat은 코드, 문서, 웹 속성에서 문제가 있는 언어를 교체하기 위해 최선을 다하고 있습니다. 자세한 내용은 다음을 참조하세요.Red Hat 블로그.

Red Hat 소개

Red Hat은 기업이 핵심 데이터 센터에서 네트워크 에지에 이르기까지 플랫폼과 환경 전반에서 더 쉽게 작업할 수 있도록 강화된 솔루션을 제공합니다.

Theme

© 2025 Red Hat