On 10/7/07, ubaggili <[EMAIL PROTECTED]> wrote: > Thanks Mike. This is exactly my issue. I do wish to be able to flush the > write queue from within mesageReceived. I'm not building an application > from scratch. What I'm doing is building a server/client application where > a sequence of calls/requests is dectated to have responses in a certain > order. The number of requests vary but each request from the server which > in turn becomes a client call back to the originating server has to get a > response. The way mina 1 handled it suit my needs. I'm unable to think of > another way apart from reimplementing some of the mina filters which I > usually try not to do. > > It would be ideal to have a an overriden IoSession.write() method that would > allow for automatic flushing of the queue after each write (mina 1.x style) > as opposed to writing the objects in rapid succession before flushing (mina > 2.x style). My application uses the DemuxingIoHandler along with a few > codecs that will each be invoked in order depending on what is sent and/or > received (for example receiving new server requests as opposed to receiving > confirmation messages for client requests). This way, I'm able to control > the request/response cycle and step through the messages in order, thus > acheiving unique request/response cycles.
There's no difference in the behavior of a write operation between 1.x and 2.x AFAIK. To make sure the internal write request queue is flushed, you have to call .await() or .awaitUninterruptly() after each write call(): session.write(...).awaitUninterruptly(). If you are writing something in your encoder and don't want the encoded data is not merged into one buffer, you can simply call ProtocolEncoderOutput.flush() after each write() call. out.write(...); out.flush(); If you want to wait for the write request is really written out to the kernel buffer, you can additionally call await() method: out.write(...); out.flush().awaitUninterruptly(); IIUC, MINA already provides all means to fulfill your needs. Or am I missing something? Trustin -- what we call human nature is actually human habit -- http://gleamynode.net/ -- PGP Key ID: 0x0255ECA6
