Apache MINA 会话关闭回调
Apache Mina - 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 但会话实际上永远不会关闭。即,我没有真正在我的处理程序中收到回电。这可能吗?我怎样才能减轻这种风险。有人可以解释调用关闭回调需要多长时间吗?
Apache Mina - 2.0.1
I have a IoHandlerAdapter which has call backs on sessionOpened and sessionClosed. When I open a session I login to the server and start sending requests, in "sessionClosed" I just restart my application.
My application makes a check
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.
}
However I did notice that although the session.isClosing() returns true the session actually never gets closed. i.e, I dont really get the call back in my handler. Is this possible? How can I mitigate against such a risk. Can someone explain how long it takes for the close callback to be called?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
恕我直言,您应该对这种情况使用 CloseFuture,如下所示:
IMHO you should use a CloseFuture for this senario like so:
我也见过这个。我相信这可能是 MINA 层中的竞争条件:
http://mail-archives.apache.org/mod_mbox/mina-dev/200802.mbox/%[电子邮件受保护]%3E
I have seen this too. I believe this could be a race condition in the MINA layer:
http://mail-archives.apache.org/mod_mbox/mina-dev/200802.mbox/%[email protected]%3E