On Dec 14, 2007 7:56 AM, Steve Johns <[EMAIL PROTECTED]> wrote:
>
> On Dec 14, 2007 6:40 AM, mat <[EMAIL PROTECTED]> wrote:
>
> > On Dec 14, 2007 1:35 AM, Trustin Lee <[EMAIL PROTECTED]> wrote:
> >
> > > Hi Steve,
> > >
> > > On Dec 13, 2007 11:49 PM, Steve Johns <[EMAIL PROTECTED]>
> > wrote:
> > > > Thanks for Mina. It is a great project.
> > >
> > > Whenever we hear this, we become happy and try to work harder for
> > > MINA.  Thank you too!
> >
> > :D
> >
> > >
> > >
> > > > 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?).
> > >
> > > There's writeTimeout property in IoSessionConfig, so you can adjust
> > > the timeout value.  Once the write it timed out, WriteTimeoutException
> > > is raised and forwarded to your IoHandler's exceptionCaught method.
> > > And then the connection will be closed automatically.
> > >
> > > > Why
> > > > NOT accumulated writeQueue size > user defined size and exception?
> > >
> > > Could you explain this question more in detail?
> >
> > Which meant: I need close the session whenever the write queue size(buffer
> > size) for this session reaches a certain number.
>
> Yup. That was what I meant.

You can always check the size of the write request queue via
IoSession.getScheduledWriteRequests/Bytes().  You can call
IoSession.close() explicitly when it returns the greater value than
you expected.

> > > 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.
> >
> > Right.  We got the same request before and I suggested him to use some
> > cache.  Would it work for you, either?
>
> A cache sounded workable. However where should I do the MESSAGE -> byte[] ->
> > cache(If I do in IoHandler, is that kinda mixing business logic and
> > protocol
> > handler)?
>
> Can you give more hints about what the CACHE is?

In you encoder, you could maintain a Map whose key is some message key
and whose value is encoded ByteBuffer (or byte[]).  It could probably
be a LRUMap implementation that is provided by 3rd party collections
API such as Apache Commons Collections.  You could query the map if
there's already an encoded form of the message, and reuse the encoded
data if there's one in your encoder implementation.

HTH,
Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/
--
PGP Key ID: 0x0255ECA6

Reply via email to