directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Olivier Ceulemans <>
Subject [mina] Looking for advice...
Date Thu, 24 Nov 2005 22:56:05 GMT

I'm converting a blocking io server to mina (using 0.9 snapshot). My 
server handles big requests (large xml requests and large binary 
attachments) using a simple and proprietary protocol. I actually managed 
to perform a dumb port to mina without encountering major difficulties 
in just a few hours of work (thanks to your great tutorial!).

I started from the 'Reverser' sample (High-level message 
encoders/decoders & protocol handler)

However, I'm not sure I have made the right choices, the following 
points are causing me some trouble:
- In my decoder, I parse xml data to convert it to pojo containing 
business data. To do that, I must copy everything to a 
ByteArrayOutputStream and then convert to a ByteArrayInputStream that 
can be handled by traditional xml parsers. I see two problems with that:
       - My xml data is sometimes large, so it takes a lot of memory. It 
could be nice id my pojo could be constructed progressively but xml 
parsers can't be fed with bytebufers...
       - I'm not sure this processing should be done at this level (in 
the decoder) from a mina point of view.
- In my decoder, I copy binary data to temporary files and pass file 
object to the protocol handler. Again it seems like decoders should not 
perform these kind of 'heavy' operations ?
- In my encoder, I sometimes create very large bytebuffers to return data.
       - Should i create smaller bytebuffers, write them, join their 
WriteFuture before sending the next one ?

At this point, I must admit I'm a bit confused and not happy with my 
solution that eats a lot of memory compared to the old blocking IO 
solution (however I understand that it can admit a larger number of 
connections without  killing the jvm in context switching operations).

After searching, I saw a solution in the StreamIOHandler. But, I don't 
see clearly what this brings (in term of performance) compared to a 
blocking IO solution. I insepcted the code, and it looks like it create 
one thread per session like a standard blocking IO solution.

After much thinking, I think that what could be the best for me is a 
StreamIOHandler that only spans the time of a request/response cycle of 
my server and that could be reused in a threadpool. Is it possible to do 
that with mina ?

==>Don't hesitate to point me to background information: I'm aware I 
might not have comletely understood the underlying phylosophy of mina.

Thanks in advance,

View raw message