8 Replies Latest reply on May 30, 2007 8:17 AM by Tim Fox

    Listing JMS Messages using JMX doesn't give full message

    mskonda Apprentice

      I have developed set of tools to "browse" messages on destinations for Kabutar. The approach I've taken is to use JBoss JMS MBeans rather than clumsy JMS QueueBrowser.

      I am able to create/fetch the MBean responsible for the destination of my interest, however, when I try to have a peek at the message content, I don't get anything except printing:

      JBossMessage[0]:NON-PERSISTENT
      JBossMessage[0]:NON-PERSISTENT

      etc..

      I get null when I tried getting the text (after convesion to TextMessage) from the message.

      here's my test code:

       public void testQueueInfo() throws Exception
       {
       String name = "testSecuredQueue";
       logger.info("Deploying the queue - " + name);
       MBeanServerConnection mBeanServer = lookupMBeanServerProxy(new InitialContext());
       ObjectName serverObjectName = new ObjectName(
       "jboss.messaging.destination:service=Queue,name=" + name);
       ArrayList o = (ArrayList) mBeanServer.invoke(serverObjectName,
       "listAllMessages", new Object[0], new String[0]);
       for (Iterator i = o.iterator(); i.hasNext();)
       {
       Message msg = (Message)i.next();
       logger.info("Message: " + msg);
       TextMessage txtMsg = (TextMessage)msg;
       logger.info("TxtMessage: " + txtMsg.getText());
       }
       }
      

      The same happens when you access litAllMessages method via JMX Browser

      Any pointers?

      Thanks
      Madhu

        • 1. Re: Listing JMS Messages using JMX doesn't give full message
          Tim Fox Master

          This is probably because the messages aren't serializable.

          It would be a fairly simple matter to make them serializable.

          Madhu- can you add this in JIRA against 1.4.0.CR1?

          • 2. Re: Listing JMS Messages using JMX doesn't give full message
            Jay Howell Apprentice

            Hey Madhu

            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25411]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25412]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25413]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25414]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25415]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,360 INFO [HelloWorldService] Message: JBossMessage[25416]:NON-PERSISTENT
            16:47:04,360 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,361 INFO [HelloWorldService] Message: JBossMessage[25417]:NON-PERSISTENT
            16:47:04,361 INFO [HelloWorldService] TxtMessage: some text
            16:47:04,361 INFO [HelloWorldService] Message: JBossMessage[25418]:NON-PE

            I ran the test and the tests seem to come out fine. I've tried persistent and non persistent messages. I can't reproduce your error. I did not change your case.

            Using your code you should be able to see at least the "TxtMessage:" text with no message.
            Your output that you showed above does not show that. The output that you showed above is the default toString() which does not look like it includes the message.

            • 3. Re: Listing JMS Messages using JMX doesn't give full message
              Jay Howell Apprentice

              I just ran an external client against the message. Here's what I get ....

              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null
              Message: JBossMessage[0]:NON-PERSISTENT
              TxtMessage: null

              This was from an external client. If I run this from inside of an MBean, it is fine. You should be able to get these running locally in an MBean as a workaround.
              Jay:)

              • 4. Re: Listing JMS Messages using JMX doesn't give full message
                Tim Fox Master

                Yes, that's why I made the comment about the messages are not serializable, hence you can't see them from a different VM or classloading domain.

                • 6. Re: Listing JMS Messages using JMX doesn't give full message
                  Tim Fox Master

                  This was a pretty trivial fix so I have fixed it now.

                  It will be in the next release (1.3.0)

                  • 7. Re: Listing JMS Messages using JMX doesn't give full message
                    mskonda Apprentice

                    Lovely!

                    Tim, could you tell me what the fix is (probably I'll build into my local copy)? I can't wait.. :)

                    Thanks
                    Madhu

                    • 8. Re: Listing JMS Messages using JMX doesn't give full message
                      Tim Fox Master

                      Just needed to make org.jboss.messaging.core.message.MessageSupport serializable.

                      I think that was it.

                      If you svn update from TRUNK and build from source the fix will be there