Long Polling with Java and JBoss

孤者浪人 提交于 2019-12-01 08:53:04
iirekm

The thing you're trying to implement is called server push. Each webserver/appserver has a pool of threads, say 10 threads for processing web requests, if all those threads will go into 'sleep' no other web request will be serviced until one of those 'sleeps' exists. Some solution is to increase number of those threads but then you'll eat more memory and more operating system resources (each thread costs). So yes, your implementation of 'server push' isn't scalable.

Solutions:

  • your web application can send a http request every (say) 5 secs, to check if your 'someCondition' changed, and then get the data
  • AFAIK, Tomcat (so JBoss too) already has some 'connector' for supporting such requests, so Thread.sleep() or semaphores won't be needed
  • use latest web server implementing Servlet API 3, it also has support for such long-running HTTP requests
  • read more: Online tutorials for implementing comets (server push)

JAX-WS provides support for invoking Web services using an asynchronous client invocation and supports both a callback and polling model. Have a look at:

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!