directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Trustin Lee <trus...@gmail.com>
Subject Re: [mina] ProtocolHandler interface
Date Fri, 17 Dec 2004 08:46:11 GMT
Ah, I forgot to say some important point.

MINA does all operation asynchronously.  So the response message is
not actually written to socket even if you called Session.write()
method.  ProtocolHandler.messageSent(...) is invoked by MINA when it
is actually written.

I know SEDA also does work in the similar way although it doesn't fire
any messageSent events.  There is an important point in fact.  Some
protocols are
stateless and closes the connection after the first response is
written.  Others are stateful or keep-alive-style and doesn't close
the connection if user doesn't close it.

The latter case is very easy to implement because client decides when
to close the channel. But the former case is tough to implement if we
don't get notified the message is actually written to socket.  We
can't avoid to close the socket even before the message is flushed out
actually.

The easiest solution to resolve this issue would be to make session
close request queued and delayed until all messages are flushed out. 
But this won't work if a client behaves abnormally like not reading
socket buffer even if server's write buffer is full and outgoing
message queue is not being flushed.

The better solution would be providing some timeout settings like
readTimeout and writeTimeout.  MINA will throw ReadTimeoutException or
WriteTimeoutException which extends IOException.  Socket close command
will be executed because MINA closes the connection automatically if
IOException is caught.

Please consider this point and suggest me the ways to improvement
ProtocolHandlers in MINA. :)

Cheers,
Trustin

Mime
View raw message