1

阿帕奇米娜 - 2.0.1

我有一个 IoHandlerAdapter,它对 sessionOpened 和 sessionClosed 有回调。当我打开一个会话时,我登录到服务器并开始发送请求,在“sessionClosed”中我只是重新启动我的应用程序。

我的应用程序进行检查

if(!session.isClosing()) {
   //write to socket
} else {
   //throw a runtime exception. Hopefully the sessionClosed API gets 
   //called soon and the next time this call will succeed.
}

但是我确实注意到,尽管 session.isClosing() 返回 true,但实际上会话永远不会关闭。即,我并没有真正在我的处理程序中得到回电​​。这可能吗?我怎样才能减轻这种风险。有人可以解释调用关闭回调需要多长时间吗?

4

2 回答 2

0

恕我直言,您应该像这样为此场景使用 CloseFuture:

CloseFuture future = session.close(true);
// wait until its closed, up to 1 minute
future.awaitUninterruptibly(60000L);
if (future.isClosed()) {
    System.out.println("Previous connection close completed");
}
于 2011-11-15T21:25:34.957 回答
0

我也见过这个。我相信这可能是 MINA 层中的竞争条件:

http://mail-archives.apache.org/mod_mbox/mina-dev/200802.mbox/%3C15350882.post@talk.nabble.com%3E

于 2015-05-02T18:15:48.853 回答