mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Hooman Valibeigi" <hooma...@gmail.com>
Subject Question from developers
Date Thu, 14 Sep 2006 00:14:30 GMT
Hi everybody
I have 2 questions which I think you can answer
the answers would be useful for other users who intend to use the MINA

assume we have a client that sends its requests consecutively
I tested it using MINA and I found that MINA only notifies the server side
IoHandler one time for a sequence of requests
I mean when the client sends 3 consecutive requests the server's
messageReceived method will be invoked only once
(a Request in my opinion is a package containing a request ID and data
related to the request)
so my question is how should we handle the ByteBuffer that has more than one
requests ?
the other IoSessions should not wait while the server is processing the
interminable requests of a client
in other word the server becomes busy while processing all sent and incoming
requests of one client and may never finish
If it responds to the first buffered request in ByteBuffer and leave the
remaining requests in hope that they will remain intact for the next
messageReceived invocation, it is wrong, since any remaining byte in
ByteBuffer will be released after the messageReceived method is finished
so we should read all the incoming bytes or we will lose them
I ask you what is the correct solution to handle these kind of requests ?
in short, I want to process one request per messageReceived invocation and I
expect that IoHandler will notify me again if I have unread data from
previous messageReceived calls

my second question is about writing a ByteBuffer to more than one IoSession
the algorithm I'm using is

for each session {
    buf.flip();
    buf.acquire();
    session.write(buf);
}

the problem is that it does not work correctly
flip() is not the way to go
instead I have to use buf.position(0)
could someone explain why ?
with flip, after the first write is done, the next call will write nothing
--> remaining() will return zero
refering to the sun's documentation, flip would be ok but why does it not
work here ?

please tell me the answer to the above questions or at least refer me to
good resources where I can find the solution myself
I can not find good information from MINA's documentation and examples
please someone help
Thank you in advance

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message