0 Replies Latest reply on Oct 21, 2010 12:08 PM by laures

    How to implement long polling/server push with JBoss

    laures Newbie

      Hi,

       

      i want to use http server push / long polling / whatever its called right now, in my next webservice.

       

      one way (a very bad, non scaling way) to do that is like this:

       

      @WebService(serviceName="mywebservice")

      @Stateless
      public class MyWebService {
          @WebMethod
          public String longPoll() {
               short ct = 0;
               while(someCondition == false && ct < 60) {
                   sleep(1000);  // 1 sec
                   ct++;
               }
               if (someCondition)
                   return "got value";
               else
                   return "";
          }
      }

      As i said, this dowsn't scale, but should demonstrate what i want to do. I've been looking for an alternative way and found two interesting things:

       

      I hope you can point me in the right direction.