mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Trustin Lee" <trus...@gmail.com>
Subject Re: ProtocolEncoderOutput and many ByteBuffer(s)
Date Tue, 02 Oct 2007 13:00:34 GMT
On 10/1/07, James Apfel <james.apfel@gmail.com> wrote:
> Hi,
> my ProtocolEncoder encodes a Message into many ByteBuffer(s) and I wrap them
> currently into a single ByteBuffer which I'm writing to
> ProtocolEncoderOutput. I'm however wondering if it's OK to write the
> ByteBuffer(s) straight to ProtocolEncoderOutput? I'm concerned about
> Threading issues (i.e. does MINA preserve the writing order of the
> ByteBuffers if I call IoSession.write(Message) from different Threads)!?

Every session has its internal queue to maintain the sequence of write
operations.  Therefore, you are OK to call
ProtocolEncoderOutput.write() many times in a single call.  Of course,
you might need synchronization if you implemented your own IoFilter
that employs your own thread model.  As long as you use the default
ExecutorFilter (or no ExecutorFilter), it's safe.

Please note three write() operation means three SocketChannl.write
calls.  If you want just one call, you can call mergeAll() method in

what we call human nature is actually human habit
PGP Key ID: 0x0255ECA6

View raw message