Given a binary file to use as attachment as an example: The binary file marshaler would open a stream to this file and add this stream packed as DataHandler object to the message (as attachment). The file is not moved in any way, just this reference to the input stream is moved. If you read this stream twice, you run into a StreamClosedException or something similar because a stream can't be read twice like this. Also when sending a DONE back to the file poller will maybe delete the file and when you try to access it afterwards you will run into an exception as well. So don't DONE it too early.
The ByteArrayDataSource has a backup byte buffer where the data will be stored. On each request to the stream of this data source a new stream will be generated an so you will be able to read the stream x times without errors. The big backdraw of this data source is the memory consumption as the byte array will occupy depending on the size of your data a lot of memory and may cause a java.lang.OutOfMemoryError in some cases. Maybe this helps you seeing things more clear. Regards Lars Am Dienstag 26 August 2008 06:01:37 schrieb Johnson George: > Thanks Sachin. > > ByteArrayDataSource works great and I see my attachement contents. But what > difference it makes using ByteArrayDataSource over StreamDataSource espl > while adding attachement?
