Hi Hooman,
On 9/14/06, Hooman Valibeigi <[EMAIL PROTECTED]> wrote:
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
Please refer to SumUp example. It demonstrates the use of
DemuxingProtocolCodecFactory.
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 ?
It is because the I/O thread will move the position when it writes the
buffer you specified. So you have to duplicate the buffer:
buf.flip();
for each session {
session.write(buf.duplicate());
}
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
We need to update our FAQ and tutorial very soon. We are receiving this
kind of fundamental questions. Sorry about your inconvenience!
HTH,
Trustin
--
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP key fingerprints:
* E167 E6AF E73A CBCE EE41 4A29 544D DE48 FE95 4E7E
* B693 628E 6047 4F8F CFA4 455E 1C62 A7DC 0255 ECA6