3 Replies Latest reply on Aug 30, 2010 3:57 AM by eugene-71

    How to list connected users?

    eugene-71

      Hello,

       

      We use JBoss 6 with HornetQ. Clients (swing application) calls EJB3 remote methods and use JMS to subscribe on topics. All calls authorised with an application-policy defined in login-config.xml.

       

      I need to maintain list of "online" users, so I have two questions:

       

      1. How can I list users, which currently have JMS connections? Via JMX I can use JMSServerManager, which have listConnectionIDs() method. However, how can I convert connection ID to caller's Principal?

       

      2. How can I catch "connection closed" events? I need this to maintain actual list of online users, so if user close application (or app crashed, so JMS connection timed out) - I should mark user as "offline".

       

      Thank you.

        • 1. Re: How to list connected users?
          eugene-71

          Well, I found a way to maintain list of online users - JMS connection, which is actually HornetQConnection, have method getInitialSession(), which returns DelegatingSession, which have method getName(). And this name match with session id, which I can get on server using listSessions().

           

          So, on init client send name of initial session to server via EJB call, and server maintain table with users and their session ids. Then, server will periodically call listConnectionIDs()/listSessions() and check which users have active sessions.

           

          But this way looks like dirty hack, so there should be a better way, eh?

          • 2. Re: How to list connected users?
            jmesnil

            Eugene Romanenko wrote:

             

            But this way looks like dirty hack, so there should be a better way, eh?

            https://jira.jboss.org/browse/HORNETQ-416

             

            We'll add more info returned by listConnections() including the remote address and the caller principal

            • 3. Re: How to list connected users?
              eugene-71

              Thank you, Jeff. Looking forward for new versions of jboss/hornetq...