9 Replies Latest reply on Jun 21, 2011 9:29 AM by rhinmass

    Scheduled messages in HornetQ

    Petya K Newbie

      Hi to all,

       

      Is there a way to get the scheduled messages' bodies, not only headers, using listScheduledMessages (or in some other way)? As I see, listScheduledMessages() returns a map of all message's properties, but not its body. In JBoss5 I was able to get and display the message body as well.

      Thanks in advance.

        • 1. Re: Scheduled messages in HornetQ
          Clebert Suconic Master

          In JBoss5 I was able to get and display the message body as well.

           

          How you were doing that? what method? In JBoss Messaging?

          • 2. Re: Scheduled messages in HornetQ
            Petya K Newbie

            The same method listScheduledMessages() then returned List<javax.jms.Message> and I could get the whole message. Now, as I see, listScheduledMessages() returns maps only of message headers.

             

            I only want to know if in HornetQ it's possible to see the whole scheduled message or not, in order to change my code accordingly.

            • 3. Re: Scheduled messages in HornetQ
              Clebert Suconic Master

              I don't think listScheduledMessages ever returned the message on the management operation.

               

               

              If you are inside the same server, you would be able to find the PostOfficeImpl and play directly with QueueImpl, and call getScheduledMessages there.

               

               

              I don't think it makes sense to return the whole message on QueueImpl::getScheduledMessage.

               

               

              You can however "hack" your version and add the method yourself on QueueControlImpl / QueueControl interface. And we may consider adding the method if you proof a good use case.

              • 4. Re: Scheduled messages in HornetQ
                Petya K Newbie

                Thanks, but since I am new to HornetQ - how do I get the PostOfficeImpl?

                • 5. Re: Scheduled messages in HornetQ
                  Clebert Suconic Master

                  You would need to do it outside of JMX. Through JBoss Micro Container, getting the Bean by its name on hornetq-jboss-beans.xml.

                   

                   

                  Do you really need that? The reason we didn't add it to management is because Messages are not serializable and you can't access the operation outside of JBoss.

                  • 6. Re: Scheduled messages in HornetQ
                    Petya K Newbie

                    Well, that's how I was getting the whole scheduled messages before:

                     

                    Hashtable<String, String> attributes = new Hashtable<String, String>(2);

                    attributes.put("name", queueName);

                    attributes.put("service", "Queue");

                           

                    ObjectName  objectName = new ObjectName("jboss.mq.destination", attributes);

                    List<Message> scheduledMessages = (List<Message>)mbServer.invoke(objectName, "listScheduledMessages",  new Object[]{}, new String[]{});

                     

                    And this returned the whole messages. Isn't there a similar way now? If not, or if it's too complicated, I'll consider changing the program to show only the properties.

                    • 7. Re: Scheduled messages in HornetQ
                      Clebert Suconic Master

                      That was jboss-mq/JBoss Messaging. We don't want to support that on HornetQ

                      • 8. Re: Scheduled messages in HornetQ
                        Clebert Suconic Master

                        I don't have an example now... but if you used JBoss Micro Container methods, you would be able to locate the bean named HornetQServer,

                         

                        With an instance of HornetQServer, you would be able to:

                         

                         

                        horneTQServer.locateQueue(SimpleString queueName).getScheduledMessages();

                         

                         

                         

                        However... what you're doing is really a hack. You are invading the messaging implementation (as you were before) to get the list of scheduled messages.

                         

                        I would review your testcase to see if you really need that.

                         

                         

                        You probably are aa good on google as I am. Look for Kernel and Micro Container, and find a method to access the HornetQServer, you will have to use the name defined on horentq-beans.xml.

                        1 of 1 people found this helpful
                        • 9. Re: Scheduled messages in HornetQ
                          rhinmass Newbie

                          I am also using the "hack" described above, but would like to change my ways and use

                          hornetQServer.locateQueue()

                           

                          I have not be able to find an example, though. I want to access this from a webapplication running from a war in the same container as the hornetQ, so I'm not sure tha the Micro Container is relevant in this case?

                           

                          I looked up the bean name in hornetq-jboss-beans.xml and it is named "HornetQServer".

                           

                          Thanks for any help!