You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@directory.apache.org by Trustin Lee <tr...@gmail.com> on 2005/07/24 03:13:44 UTC

Re: Mina close and flush

Hi Magnus,

2005/7/24, Magnus Naeslund(k) <ma...@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/

Re: Mina close and flush

Posted by Vinod Panicker <vi...@gmail.com>.
On 7/24/05, Trustin Lee <tr...@gmail.com> wrote:
> Hi Magnus,
> 

--snip--

>  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.9 has 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.  

I'd definitely recommend using the 0.9 stream even though its
SNAPSHOT.  Much cleaner API and no issues as of now.

Regards,
Vinod.