On Dec 17, 2007 12:17 PM, Trustin Lee <[EMAIL PROTECTED]> wrote:
> On Dec 15, 2007 11:55 AM, Steve Johns <[EMAIL PROTECTED]> wrote:
> > On Dec 15, 2007 5:52 AM, Mike Heath <[EMAIL PROTECTED]> wrote:
> >
> > > Steve Johns wrote:
> > > > Thanks for Mina. It is a great project.
> > > > After I am trying out the Mina, I had some questions.
> > > > 1) If the server session.write() a message, however client network
> is
> > > really
> > > > SLOW. Will mina keep trying to send
> > > > out the message until timeout?(I guess session.settimeout() is
> applied
> > > > here). If so, how IoHandler get notified from this
> > > > event message? (Through exceptionCaught, close session?). Why NOT
> > > > accumulated writeQueue size > user defined size and exception?
> > >
> > > MINA only passes the message on to the OS once. It is the OS'
> > > responsibility to manage TCP timeouts and resend dropped packets. If
> > > the TCP connection timesout, an exception will be thrown and it can be
> > > handled in IoHandler.exceptionCaught.
> >
> > I may not make myself clear. If I send 100 bytes length of packets,
> however,
> > only 50 bytes are sent. (int sentBytes = socket.write(bytes[])). I
> meant if
> > Mina will put the left 50 bytes back to the queue and send them again?
>
> Yes. MINA will try to send when the NIO selector tells MINA that the
> kernel buffer is reday to receive more write requests.
So Mina will keep re-sending the packets which sent failure last time? I
meant re-send the left 50bytes[] in my example?
>
>
> > > > 2) If the server wants to send the same message to all 1000
> sessions,
> > > should
> > > > I encode the same message 1000 times
> > > > in the encoder extend the messageEncoder? If so, that kinda affects
> the
> > > > performance.
> > >
> > > If you send the message as a Java Object, it will have to be encoded
> > > 1,000 times. If you're going to be broadcasting a message to lots of
> > > clients, I would recommend encoding it once, and then doing something
> > > like:
> > >
> > > for (IoSession session : allRecipients) {
> > > session.write(myEncodedBuffer.duplicate());
> > > }
> >
> > Which means I have to do the Encode part in the IoHandlerAdapter but NOT
> in
> > my encoder, right? That really mixes up the communication and business
> > logic.
>
> Well, it doesn't necessarily mean that. You can use some cache in
> your encoder to avoid encoding the same message over and over, not
> hurting the separation of concerns.
>
> > > > Finally, thanks Trustin.
> > >
> > > Yes, Trustin is my hero.
> >
> > You are my hero, too. :)
>
> Any costume for me? :D
>
> HTH,
> Trustin
> --
> what we call human nature is actually human habit
> --
> http://gleamynode.net/
> --
> PGP Key ID: 0x0255ECA6
>