You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Michal <ca...@yahoo.com> on 2007/10/30 10:12:09 UTC

Streams in NormalizedMessage

I see that JBI API support streams - which is very good. However, one problem
with stream is that in most cases you can digest it just once. Fortunately,
JBI API uses stream factories (Source, DataHandler) - not streams directly.
So now everything depends on the factory: does it return new stream every
time client ask for it (dynamic factory) OR does it return the same stream
always (static factory).

To make the discussion more productive I will put an example:
I have two endpoints: jms consumer, bean provider. Jms consumer sends a
message using DataHandler (cause the message is not xml). In Bean provider I
would like to: process the message (using Reader) and if processing fails I
would like to save the message in a file (again using Reader). Then I will
send DONE to the consumer so it will acknowledge the message consumption in
the JMS.

Now if Stream factory (in this case DataHandler) returns always the same
stream (Static Factory) then I will not be able to store the message in a
file when processing fails (cause the reader will be already read).


Questions:
* is it acceptable (by the design) to process more than once a message by
the provider? i think it has to be cause what if SM internally logs the
message - in case of Static Factory logging would affect provider (it will
not be able to read the message)
* is there an API which can tell that a Stream factory is static or dynamic?
if not wouldn't be useful to add it in future releases? With such API if I
had a static factory then before processing (if I want to process a message
many times) I would either put all bytes into a memory or I would put them
into a temporary file.
* currently I can:
1. assume that provider always gets dynamic factories
2. assume that provider always gets static factories and before processing
put the bytes into a memory or a file
3. I could have a flag (in a NormalizedMessage property) which says whether
the factory is static or dynamic and then behave respectively.
4. any other solution? Did I missed any important thing?

thanks
Michal
-- 
View this message in context: http://www.nabble.com/Streams-in-NormalizedMessage-tf4717270s12049.html#a13484860
Sent from the ServiceMix - User mailing list archive at Nabble.com.