我们知道,在MINA2中,发送和接受时两个独立的工作线程,但是可以设置一个参数,当服务端发送消息之后同步读取客户端的返回:
session.getConfig().setUseReadOperation(true);
近日,采用MINA2(RC)的同步读取方法,发现无法真的同步读取客户端的返回;
场景是:服务端发送一个消息给客户端,需要同步等待客户端的一个消息回执,然后服务端的程序继续执行;
sendSession.getConfig().setUseReadOperation(true);
WriteFuture future = sendSession.write(xmlMsgBean); // 发送数据
future.awaitUninterruptibly(); // 等待发送数据操作完成
if (future.getException() != null) {
throw new AppException(future.getException().getMessage());
}
if (future.isWritten()) {
// 数据已经被成功发送
logger.debug("数据已经被成功发送");
ReadFuture readFuture = sendSession.read();
readFuture.awaitUninterruptibly();
if (readFuture.getException() != null) {
throw new AppException(readFuture.getException().getMessage());
}
sendSession.getConfig().setUseReadOperation(false);
return ((XmlMsgBean) readFuture.getMessage()).getStrErrMsg();
} else {
// 数据发送失败
logger.debug("数据发送失败");
}
后来用GOOGLE搜索了一下,发现在MINA的官网上,老外同样问了一个一模一样的问题,并且提了一个BUG上去,但是目前BUG的状态还是open;
https://issues.apache.org/jira/browse/DIRMINA-777
I'm attempting to perform a synchronous write/read in a demux-based client application with MINA 2.0 RC1, but it seems to get stuck. Here is my code:
{code}
public boolean login(final String username, final String password) {
// block inbound messages
session.getConfig().setUseReadOperation(true);
// send the login request
final LoginRequest loginRequest = new LoginRequest(username, password);
final WriteFuture writeFuture = session.write(loginRequest);
writeFuture.awaitUninterruptibly();
if (writeFuture.getException() != null) {
session.getConfig().setUseReadOperation(false);
return false;
}
// retrieve the login response
final ReadFuture readFuture = session.read();
readFuture.awaitUninterruptibly();
if (readFuture.getException() != null) {
session.getConfig().setUseReadOperation(false);
return false;
}
// stop blocking inbound messages
session.getConfig().setUseReadOperation(false);
// determine if the login info provided was valid
final LoginResponse loginResponse = (LoginResponse)readFuture.getMessage();
return loginResponse.getSuccess();
}
{code}
I can see on the server side that the LoginRequest object is retrieved, and a LoginResponse message is sent. On the client side, the DemuxingProtocolCodecFactory receives the response, but after throwing in some logging, I can see that the client gets stuck on the call to `readFuture.awaitUninterruptibly() `.
I can't for the life of me figure out why it is stuck here based upon my own code. I properly set the read operation to true on the session config, meaning that messages should be blocked. However, it seems as if the message no longer exists by time I try to read response messages synchronously.
Key: DIRMINA-777
Type: Bug
Status: Open
Priority: Blocker
Assignee: Unassigned
Reporter: Matt Huggins
Votes: 0
Watchers: 0
分享到:
相关推荐
我自己写的使用mina框架实现cmpp2.0服务端,经过一段使用解决了几个bug现在比较稳定。
Apache MINA(Multipurpose Infrastructure for Network Applications) 是 Apache 组织一个较新的项目,它为开发高性能和高可用性的网络应用程序提供了非常便利的框架。当前发行的 MINA 版本支持基于 Java NIO 技术的...
mina-touch,一个方便、轻量的 小程序 手势事件监听库 事件库部分逻辑参考alloyFinger,在此做出声明和感谢 change log: 2019.03.10 优化监听和绘制逻辑,动画不卡顿 2019.03.12 修复第二次之后缩放闪烁的 bug,...
分享出来主要就是看不惯太多做这个还收费的(收费就算了,有些还骗人,自己也不是大拿,如果有BUG可以反馈给我,我尽力改)。自己赚点积分下载其他资源用,实在没积分下载的可以留言邮箱,博主不定时发邮件。
我已经包含了一个100 DummyWorkUnits的测试。 这些只是等待几秒钟然后停止的作业。 作业编号6配置为在运行时引发异常。 要启动服务器,请运行编译脚本。 这将编译所有类并启动服务器。 然后,使用compile2脚本在...
使用方法见:https://blog.csdn.net/upset_ming/article/details/96491058 1. 修改了前一版本中证书验证的bug,支持JDK8的高版本 2. 支持国密SSL双向认证 3. 将过期的国密证书替换为新证书
执行以下操作前请确保正确安装了:Node.js 环境微信开发者工具(bug很多,注意保持更新)一个得心应手的文本编辑工具(不要用微信开发者工具当编辑器)安装 wepy在终端中执行:npm install wepy-cli -g如果安装遇到...
在实现页面跳转的时候,js数据无法在wxml 中渲染(不知道这个词对不对,有点逼格),没有出现 (此图片来源于网络,如有侵权,请联系删除! ) 要跳转页面的js //detail.js var app = getApp() Page({ /** * 页面...
Apache FtpServer是一个100%纯Java的、基于现有开放式协议基础上、完整、小巧的FTP服务器。此外,FtpServer还可以作为Windows服务器、Unix / Linux后台程序或是被嵌入在Java应用程序而独立运行。有了MINA...
5、本人与朋友已经为消灭Bug做出了很多努力,但仍然不乏一些尚未实现或存在bug的功能,有不合理的地方望您容忍^-^; 6、该应用对于想要总结JavaSe基础的同学,或者想要尝试JAVA Swing的同学,亦或想要参考制作...
[bug](#bug) - [设计模式](#pattern) - [客户端](#client) - [工具类](#utils) - [游戏内实现](#game) - [其他](#other) **服务端** [↑](#toc) ServerMain.java 服务端入口类,调用TetrisServer的Start()函数 ...
由于该项目使用 IntelliJ IDEA 开发,而且选用了编译 GUI 选项,因此暂时需要 IDEA 的 javac2 支持。以后可能会改变这些限制。 添加 build.properties,输入以下内容: path.variable.maven_repository={你的用户 ...
一个关于中医知识文章小程序,后台已移植到leancloud,爬虫数据和后台不方便开放(后台基于Koa2和mongoose,爬虫抓取数据保存于mongodb) 如何启动 1. ./mongod和mongo启动连接数据库,打开robomongo客户端2. npm ...
1.1.jar,log4j-1.2.14.jar,mina-core-2.0.7.jar,mssqlserver2.jar,msv-core-2011.1.jar,neethi-3.0.2.jar,oauth-20100527.jar,oauth-provider-20100527.jar,opensaml-2.5.1-1.jar,openws-1.4.2-1.jar,...
mina为小程序架构,用mpVue编写 :backhand_index_pointing_right: 为什么写小程序还会另有前端? 考虑到该项目需要相对快速开发且后期需要移植到PC端的可能性,该项目使用小程序的web-view组件引入网站的方式进行...
觉得新Funimation网站的视频播放器太小了吗? 那么这个扩展改变了这一点。...-更新5/3/2017 --- 0.1.3更新了一个错误--更新5/3/2017 --- 0.1.2视频播放器的最大尺寸增加到1920px宽(HD最大宽度) 支持语言:English
具体Bug如下所示 内心有一万匹草泥马呼啸而过,捣豉了很久,最终在某群中问了下得到了答案,解决途径如下。 打开~/.zshrc文件,找到如下两行。 # You may need to manually set your language environment # ...