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 close and flush
Date Sun, 24 Jul 2005 01:13:44 GMT
Hi Magnus,

2005/7/24, Magnus Naeslund(k) <mag@kite.se>:
> 
> Question 1: How do I close a connection in a good way making sure it has
> written everything? What i do now is to have a wrapper that when close()
> is called checks if there is any outstanding request closes the session
> immediatly, but if there is buffers queued it just sets a flag and
> checks it in the data write callback and closes it there.
> It's a hack, how can i do this in a better manner?


You can wait for messageSent event of the last message and then close. Or in 
MINA 0.9, IoSession.write() returns IoFuture object so that you can wait for 
the message to be written.

Question 2: What is the close(true) functionality about? I thought this
> was for forcing the session to flush before close, but that isn't the 
> case.


All operations are asynchronous, so the connection might not be closed even 
if you called close() method. close(true) ensures the connection is closed 
when it returns.

I would like to have this kind functionality:
> session.setFlushBeforeCloseTimeout(long ms) and then have an async
> session.closeButFlushFirst()...
> Then mina would flush everything before it closes the session, but
> trying at most X ms...


As I mentioned above MINA 0.9 returns IoFuture so that you can control it. 
You can wait for the last message to be written at maximum nnn milliseconds, 
too.

I guess you're using 0.7.4-SNAPSHOT or 0.7.3. We didn't officially released 
0.9 yet, but it is believed that 0.9-SNAPSHOT is quire stable IMHO because a 
guy called 'Vinod Panicker' is using 0.9 in his project and not reporting 
any big issues. You could try 0.9 if you really need that feature. But
0.9has a bit different (but more clean) API, so you'll have to learn a
little
bit again to migrate your code to 0.9-compatible. 

Trustin
-- 
what we call human nature is actually human habit
--
http://gleamynode.net/

Mime
View raw message