6 Replies Latest reply on May 3, 2011 9:19 AM by rhinmass

    Browse delayed messages

    rhinmass Newbie

      Hello,

       

      I am using the delayed message property :

       

          message.setLongProperty("_HQ_SCHED_DELIVERY", System.currentTimeMillis()+10000)

       

      when queueing messages.

       

      I would like  to use a QueueBrowser to peek at the queue, but the QueueBrowser does not seem to see these messages that are in the scheduled state. 

       

      Is there a way to see the messages that in the scheduled for delivery state?

       

      Thanks for any help!!

      Robin

        • 1. Browse delayed messages
          Clebert Suconic Master

          You can use Management operations to look at those.

           

          those are not delivered yet, right? Hence you can't look at those on the queue through the browsers. It doesn't make sense

          • 2. Browse delayed messages
            rhinmass Newbie

            Thanks Clebert.  How can I look at those message using management operations? I could only find javax.management.j2ee.statistics.getPendingMessageCount(),  but that is just the count.  Is there a way to peek at the actual message?

            If so, can you point me at the class I would need to use?

            • 3. Browse delayed messages
              rhinmass Newbie

              OK, I just found QueueControl.listScheduledMessages().  I was looking in the javax.*, rather than the org.hornetq.*  But since "_HD_SCHED_DELIVERY" is not jms standard anyway, it makes sense I will need to go implementation-dependent.

              • 4. Browse delayed messages
                Clebert Suconic Master

                As I said, With Scheduled Message you are saying send at a later time. The message didn't make to the JMS queues yet.

                • 5. Browse delayed messages
                  rhinmass Newbie

                  Clebert Suconic wrote:

                   

                  You can use Management operations to look at those.

                   

                  Which management operation can be used to look at the scheduled messages?

                  • 6. Browse delayed messages
                    rhinmass Newbie

                    I figured out how to this:

                     

                        MBeanServer mBeanServer  = ManagementFactory.getPlatformMBeanServer();  

                        SimpleString queueId = new SimpleString("jms.queue.MyQueue");   

                        ObjectName on = ObjectNameBuilder.DEFAULT.getQueueObjectName(queueId, queueId);

                     

                        Map<String,Object>[] maps =

                             (Map<String,Object>[])  mBeanServer.invoke(on, "listScheduledMessages", new Object[0], new String[0]);

                     

                        for (Map<String,Object> map : maps)

                        {   

                              long schedTime =  ((Long)map.get("_HQ_SCHED_DELIVERY")).longValue();

                              System.out.println("message " + map.get("messageID") + "is scheduled for delivery on " + new Date(schedTime));

                        }