I am looking for an example how to implement longpoling mechanism in java. I would love to use stateless EJB.
I know something like this will work:
@WebService(serviceName="mywebservice")
@Stateless
public class MyWebService {
@WebMethod
public String longPoll() {
short ct = 0;
while(someCondition == false && ct < 60) {
sleep(1000);
ct++;
}
if (someCondition)
return "got value";
else
return "";
}
}
Unfortunately, I know that this does not make scale. Can I return to the web method without completing the answer and end it somewhere else?
source
share