什么 bug,你不说大家咋知道呢
解决方案 »
- hibernate映射2张表
- xsd报错,the prefix "xml" cannot be bound to any namespace other its usual ...
- 简单的webservice 调用问题 顶的也给分
- 请问在linux下开发jsp程序用什么开发工具?
- 关于访问文件资源的同步问题
- 那里有jspSmartUpload组件下载
- 求助:一个json解析问题
- 在servlet中如何调用javabeans
- 关于resin的问题
- 在apache2+tomcat4環境下,怎樣設置使我輸入ip地址後,自動運行index.jsp
- web项目链接mysql时出现错误,几天也没弄好,求救!!!!
- java做服务器
public ModelAndView subscribe(HttpServletRequest request,
HttpServletResponse response) throws Exception {
AtmosphereResource resource = (AtmosphereResource) request
.getAttribute(FrameworkConfig.ATMOSPHERE_RESOURCE);
this.doGet(resource, request, resource.getResponse());
ModelAndView mv = new ModelAndView(new NoOpView());
return mv;
} @RequestMapping(value = "/comet", method = RequestMethod.POST)
public ModelAndView broadcastMessage(HttpServletRequest request,
HttpServletResponse response) throws Exception {
this.doPost(request, response);
ModelAndView mv = new ModelAndView(new NoOpView());
return mv;
} protected void doGet(AtmosphereResource resource,
HttpServletRequest request, AtmosphereResponse response) {
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0); String path = request.getParameter("path");
if (path == null || path.isEmpty() == true) {
sendError(resource, "");
return;
}
int userId = 0;
try
{
//从当前请求中获取,用户ID
}
catch (Exception e)
{
e.printStackTrace();
DebugUtil.log("Comet userId error: ");
DebugUtil.log(e.toString() + "\n" + DebugUtil.getStack(e));
}
if (userId == 0)
{
sendError(resource, "");
return;
}
Integer number=addUserToroomsource(resource.uuid(),userId, path);
Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup("/" + path, true);
resource.setBroadcaster(broadcaster);
resource.addEventListener(new myAtmosphereResourceEventListener());
resource.suspend();
} private Integer addUserToroomsource(String uuid, int userId, String path) {
return null;
} private void sendError(AtmosphereResource resource, String errorMessage) {
sendError(resource, errorMessage, "");
} public static void sendError(AtmosphereResource resource,
String errorMessage, String errorInfo) {
StringBuilder json = new StringBuilder("{\"result\": \"");
json.append(errorMessage);
json.append("\"");
if (errorInfo != null) {
json.append(", \"message\": \"");
json.append(errorInfo);
json.append("\"");
}
json.append("}");
Broadcaster b = BroadcasterFactory.getDefault().lookup("/error", true);
b.addAtmosphereResource(resource);
b.broadcast(json.toString()); } protected void doPost(HttpServletRequest request,
HttpServletResponse response) {
JSONObject jsonObject = null;
String path = null;
String message = null;
try {
String str = request.getReader().readLine();
if (str != null) {
jsonObject = new JSONObject(str);
}
} catch (Exception e) {
}
if (!jsonObject.isNull("path")) {
path = jsonObject.getString("path");
}
if (!jsonObject.isNull("message")) {
message = jsonObject.getString("message");
}
AtmosphereResource resource=(AtmosphereResource)
request.getAttribute(ApplicationConfig.SUSPENDED_ATMOSPHERE_RESOURCE_UUID);
Broadcaster broadcaster = BroadcasterFactory.getDefault().lookup("/" + path);
if (broadcaster != null) {
broadcaster.broadcast(message);
}
}
光看get/post,没啥问题。
光看get/post,没啥问题。整个程序就是这2个方法,get(请求被压住),post(接受数据,激活被压住的连接--广播)
部署到服务器才会出现BUG,在本地测试,或者访问量很小的情况不会出现。就不知道如何在本地进行模拟访问???
也可以参考下:
sql 性能模拟用户测试
都用过了,没有用,LoadRunner 11 录制脚本,运行的时候会报错,一直会说资源找不到。
JMeter 只能模拟http请求,不能加载js,因为请求都是js去做的事情
sql 性能模拟用户测试
这点访问量 恐怕不够,我还是想想自己写脚本,谢谢你的提议。我也与框架作者交流过,一直没找出问题的原因所在,很是困惑。这不一定是框架的问题,现在的问题是你根本就不知道是哪里的问题。我也一直在查找自身代码的原因,只能有一套完整的测试方法了,我才能去判断到底问题在哪里,请问你对tomcat的集群了解如何?
现在考虑做,tomcat集群。但是主站项目的原因,不能与apache集成。现在的设想是N个tomcat集群,如何保证能共享广播数据? RedisBroadcaster 这个atmosphere 插件用过没?这个就是做集群的广播类,我现在配置上去有点问题,启动项目会报错: java.net.ConnectException: Connection refused: connect