I\'m looking for an example, how to implement a longpoling mechanism in java. I would love to use a stateless EJB.
I know that something like that would work:
<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:
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: