2 Replies Latest reply on Nov 13, 2003 10:49 AM by ThomasMargreiter

    Statefull sessionbean ... acting as SessionCounter for all c

    ThomasMargreiter Newbie

      hi there !
      i want to make a sessionObserver Object which contains some information about all current registered clients! i tried to do this with a SINGELTON OBJECT in a stateless Sessionbean ! all setter and getter methods were synchronized but the system hangs after a while ! .... looks like a deadlook !

      is there a way to create a statefull sessionbean which can be accessed from each client so that it can act as a 'sessionObserver' object ?

      or is there another possible solution in EJB ?

        • 1. Re: Statefull sessionbean ... acting as SessionCounter for a
          jamesstrachan Newbie

          I would guess that your use of a synchronized object is interfering with JBoss also using synchronized objects to handle multiple threads. But that could be very difficult to prove.

          Entity Beans normally handle persistent data, but you could use an Entity Bean which only contains a list of current sessions. There would be no underlying persistent data, but the list should survive passivation and activation.

          That way, JBoss would handle all the threading issues.

          How do you plan to know which users are registered ?

          If you are using stateful session beans, you can add a user during ejbCreate() of the session bean and remove the user during ejbRemove(). But sessions that time out will not be removed.

          James



          • 2. Re: Statefull sessionbean ... acting as SessionCounter for a
            ThomasMargreiter Newbie

            OK !
            i have made a MBean which contains all my SessionData ... so i have no probrem with synchronizing (i think this will be done by JBOSS)

            the registration of the clients is very simple because my client's are java-client ... not Web-clients ... i generate a sessionKey containing ip,portnumber and timestamp ... with this function i can also control the number of sessions on a client each session starts a thread on the client - the client-thread send permanent a "I'm alive message" and so on ...