Hello all,

I've a few quick questions regarding byte buffers and recycling in Mina.

Let's say I've got two connections to a Mina server.  I'm sending messages 
consisting of a "header" and "body" and I want to move messages these between 
the two connections.  The header on the incoming message will be stripped off 
and replaced with a new header before the message is sent to the other 
connection.  With fixed size headers I'd normally use scatter gather operations 
to efficiently "parse" these messages into the two parts.  Is this still 
possible with Mina?  How would I do this?

The key to building an efficient server is to minimize GC.  To that end, my 
initial though for passing messages between these two connections is to simply 
take the byte buffer passed during messageReceived and pass it to the other 
IoSession.write(..).  But I don't think this will work properly because of byte 
buffer recycling.  The incoming byte buffer could be "recycled" by mina before 
the outgoing IoSession.write(..) happened.  This would cause corruption of the 
data.  What is the best way to move bytes between two streams without 
unnecessarily creating lots of short lived buffers or other objects?

One of the benefits of NIO is moving bytes between streams "in the kernel".  
I.E. you don't have to bring the data into "user space" to copy it from one 
stream to another and this reduces kernel context switches.  How do I take 
advantage of this in Mina?

Basically I'm looking for the most efficient way to move bytes from one stream 
to another.  These bytes will actually be "messages" with a header and body.  
The header will be changed between reception and transmission.  I also need to 
perform some routing logic using the header.  If necessary for efficiency I 
could use a fixed size header, but would prefer not to.

A rapid response would be greatly appreciated.
Thanks!
Rob






       
____________________________________________________________________________________
Moody friends. Drama queens. Your life? Nope! - their life, your story. Play 
Sims Stories at Yahoo! Games.
http://sims.yahoo.com/

Reply via email to