user2655148
user2655148

Reputation: 21

How to send any InputStream to JMS Queue?

It is not sending it because InputStream is not Serializable. Is there any option to do this? Different InputStreams will contain different sources to read from so it's better if I can send InputStream directly to JMS queue.

Upvotes: 0

Views: 1831

Answers (2)

Beryllium
Beryllium

Reputation: 12998

You cannot send a stream, you have to "materialize" it before:

  1. Read the stream into a byte array
  2. Use a BytesMessage: See writeBytes

As an alternative have a look at this BytesMessageOutputStream: This way you should be able to stream, however the BytesMessage probably needs to buffer anyway.

Upvotes: 1

tom
tom

Reputation: 2745

An inputstream generally points to some resource. This resource might not be available to the consumer of your queue.

You can convert your inputstream to a byte[] which represents the loaded resource and send it that way.

Upvotes: 0

Related Questions