8 Replies Latest reply on Nov 13, 2007 1:45 PM by timfox

    JMX Operations to expose to clients in JBM 2.0

    ataylor

      Because of the Pojoification of our mBeans I think we need to review what operations are exposed to clients via JMX. As far as i can see there are only the 3, the ServerPeer and the Topic/Queue Service.

      If we take the ServerPeer first we expose the operations by the following tag

      @JMX(name="jboss.messaging:service=Server", exposedInterface = JmsServer.class)
      public class ServerPeer implements JmsServer
      {
      ...
      }
      


      We then expose the operations via the interface, Currently this would be:
      public interface JmsServer
      {
       String getJMSVersion();
      
       int getJMSMajorVersion();
      
       int getJMSMinorVersion();
      
       String getJMSProviderName();
      
       String getProviderVersion();
      
       int getProviderMajorVersion();
      
       int getProviderMinorVersion();
      
       void enableMessageCounters();
      
       void disableMessageCounters();
      
       String deployQueue(String name, String jndiName) throws Exception;
      
       String deployQueue(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception;
      
       boolean destroyQueue(String name) throws Exception;
      
       boolean undeployQueue(String name) throws Exception;
      
       String deployTopic(String name, String jndiName) throws Exception;
      
       String deployTopic(String name, String jndiName, int fullSize, int pageSize, int downCacheSize) throws Exception;
      
       boolean destroyTopic(String name) throws Exception;
      
       boolean undeployTopic(String name) throws Exception;
      
       String listMessageCountersAsHTML() throws Exception;
      
       void resetAllMessageCounters();
      
       void resetAllMessageCounterHistories();
      
       List retrievePreparedTransactions();
      
       String showPreparedTransactionsAsHTML();
      
       String showActiveClientsAsHTML() throws Exception;
      }
      

      If you think anything should be changed/added/removed nows the time to say and I'll do it.

      With regard to Topics and Queues it may pay to do this a little differently as they'll just be created on the fly, not as beans, so there will be no operations to expose.

      We could add all these methods to the above interface and do it via the ServerPeer->PostOffice and pass down an extra parameter being the destination bind name.

      Any comments?

        • 1. Re: JMX Operations to expose to clients in JBM 2.0
          timfox

           

          "ataylor" wrote:

          With regard to Topics and Queues it may pay to do this a little differently as they'll just be created on the fly, not as beans, so there will be no operations to expose.


          Does the micro-container not support dynamically exposing an object created at runtime as a MBean?

          • 2. Re: JMX Operations to expose to clients in JBM 2.0
            ataylor

            "timfox" wrote

            Does the micro-container not support dynamically exposing an object created at runtime as a MBean?


            yes i think it does, but its a lot of extra work to create the destinations as beans (and destroy them") when they don't really need to be. If we look at say the QueueService method
            public List listAllMessages() throws Exception
            


            we expose this on the ServerPeer and the implementation is simply
            public List listAllMessages(String queueName) throws Exception
             {
             return ((ManagedQueue) getDestinationManager().getDestination(queueName, true)).listAllMessages(null);
             }
            


            This also keeps a single simple API for the client to use and a single point of entry.

            what do you think?

            • 3. Re: JMX Operations to expose to clients in JBM 2.0
              ataylor

              also, this helps define the differences in abstraction between the serverpeer and the postoffice.

              • 4. Re: JMX Operations to expose to clients in JBM 2.0
                timfox

                 

                "ataylor" wrote:

                This also keeps a single simple API for the client to use and a single point of entry.

                what do you think?


                Ok, you sold it :)

                Perhaps we should create a class called "Configuration" which maintains all the server peer attributes rather than the serverpeer directly.

                And going a little further I don't think we should expose the post office attributes directly but also have them set/get on the Configuration class.

                We can keep the post office class internally, but I don't think the user needs to see it.

                • 5. Re: JMX Operations to expose to clients in JBM 2.0
                  ataylor

                  I think thats a good idea, it also means that the user never needs to edit the jboss-beans.xml config file, just the configuration

                  • 6. Re: JMX Operations to expose to clients in JBM 2.0
                    ataylor

                    Actually I've had a rethink. Moving all the methods form topic/queuembean into ServerPeer makes it a bit monolithic. I think creating and exposing a new interface say 'JmsServerStatistics' for these methods would be a bit more elegant.

                    something like

                    public interface JmsServerStatistics
                    {
                    
                    
                     int getMessageCountForQueue(String queue) throws Exception;
                    
                     int getDeliveringCountForQueue(String queue) throws Exception;
                    
                     int getScheduledMessageCountForQueue(String queue) throws Exception;
                    
                     MessageCounter getMessageCounterForQueue(String queue);
                    
                     MessageStatistics getMessageStatisticsForQueue(String queue) throws Exception;
                    
                     int getConsumerCountForQueue(String queue) throws Exception;
                    
                     void resetMessageCounterForQueue(String queue);
                    
                     void resetMessageCounterHistoryForQueue(String queue);
                    
                     List listAllMessagesForQueue(String queue) throws Exception;
                    
                     List listAllMessagesForQueue(String queue,String selector) throws Exception;
                    
                     List listDurableMessagesForQueue(String queue) throws Exception;
                    
                     List listDurableMessagesForQueue(String queue,String selector) throws Exception;
                    
                     List listNonDurableMessagesForQueue(String queue) throws Exception;
                    
                     List listNonDurableMessagesForQueue(String queue,String selector) throws Exception;
                    
                     String listMessageCounterAsHTMLForQueue(String queue);
                    
                     String listMessageCounterHistoryAsHTMLForQueue(String queue);
                    
                     //topic
                    
                     int getAllMessageCountForTopic() throws Exception;
                    
                     int getDurableMessageCountForTopic() throws Exception;
                    
                     int getNonDurableMessageCountForTopic() throws Exception;
                    
                     int getAllSubscriptionsCountForTopic() throws Exception;
                    
                     int getDurableSubscriptionsCountForTopic() throws Exception;
                    
                     int getNonDurableSubscriptionsCountForTopic() throws Exception;
                    
                     // JMX operations
                    
                     void removeAllMessagesForTopic(String topic) throws Exception;
                    
                     List listAllSubscriptionsForTopic(String topic) throws Exception;
                    
                     List listDurableSubscriptionsForTopic(String topic) throws Exception;
                    
                     List listNonDurableSubscriptionsForTopic(String topic) throws Exception;
                    
                     String listAllSubscriptionsAsHTMLForTopic(String topic) throws Exception;
                    
                     String listDurableSubscriptionsAsHTMLForTopic(String topic) throws Exception;
                    
                     String listNonDurableSubscriptionsAsHTMLForTopic(String topic) throws Exception;
                    
                     List listAllMessagesForTopic(String topic,String subscriptionId) throws Exception;
                    
                     List listAllMessagesForTopic(String topic,String subscriptionId, String selector) throws Exception;
                    
                     List listDurableMessagesForTopic(String topic,String subscriptionId) throws Exception;
                    
                     List listDurableMessagesForTopic(String topic,String subscriptionId, String selector) throws Exception;
                    
                     List listNonDurableMessagesForTopic(String topic,String subscriptionId) throws Exception;
                    
                     List listNonDurableMessagesForTopic(String topic,String subscriptionId, String selector) throws Exception;
                    
                     List getMessageCountersForTopic(String topic) throws Exception;
                    }
                    


                    Also with very little work we could expose these to the user via an abstraction so they dont have to worry about JMX etc.

                    something like

                    
                    public void connect(InitialContext initialContext)
                     {
                     connect(initialContext, null, null);
                     }
                    
                     public void connect(InitialContext initialContext, String user, String password)
                     {
                     this.initialContext = initialContext;
                     this.user = user;
                     this.password = password;
                     }
                    
                     public JmsServer getServer()
                     {
                     return (JmsServer) Proxy.newProxyInstance(JmsServer.class.getClassLoader(),
                     new Class[] { JmsServer.class },
                     new JmsServerInvocationHandler(initialContext));
                    
                     }
                    
                     public JmsServerStatistics getServerStatistics()
                     {
                     return (JmsServerStatistics) Proxy.newProxyInstance(JmsServerStatistics.class.getClassLoader(),
                     new Class[] { JmsServerStatistics.class },
                     new JmsServerStatisticsInvocationHandler());
                     }
                    
                     public static void main(String[] args) throws Exception
                     {
                     Admin admin = new Admin();
                     Hashtable env = new Hashtable();
                     env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
                     env.put("java.naming.provider.url", "jnp://localhost:1099");
                     env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
                    
                     InitialContext ic = new InitialContext(env);
                     admin.connect(ic);
                     JmsServer server = admin.getServer();
                     server.getJMSMajorVersion();
                     }
                    }
                    
                    


                    • 7. Re: JMX Operations to expose to clients in JBM 2.0
                      timfox

                       

                      "ataylor" wrote:
                      Actually I've had a rethink. Moving all the methods form topic/queuembean into ServerPeer makes it a bit monolithic. I think creating and exposing a new interface say 'JmsServerStatistics' for these methods would be a bit more elegant.


                      Yes, this is a nice idea.


                      • 8. Re: JMX Operations to expose to clients in JBM 2.0
                        timfox

                        One thing we also need to consider.

                        Currently users can deploy their destinations and connection factories in arbitrary files as long as they specify the correct MBeans.

                        If we put all the destination / cf config in single files then would disallow users from doing this.

                        Also, users can currently deploy / undeploy destinations while the server is running by editing and saving (or touching) the file (redeploy) or deleting it (undeploy).

                        We should support really support something similar.