1 2 Previous Next 17 Replies Latest reply on Jul 11, 2014 9:37 AM by lauradp

    Some questions about QueueBrowsers

    lauradp

      Hello everybody,

      I added some messages to a queue with a "_HQ_SCHED_DELIVERY" property.

      Then I wrote a QueueBrowser that lists all messages in the queue, but I get a not null result only if alla consumers in the queue are turned off (even if they were iddle because of "_HQ_SCHED_DELIVERY" property).

      (Question #1) How can I have messages listed when consumers are linstening on the queue?

       

      Given a messageId I run the following code to update message priority:

       

      message.setJMSPriority(newPriority.intValue());

      trace.debug("updatedPriority of message " + messageId);

      trace.info("new priority: " + message.getJMSPriority());

       

      but if I list messages in the queue I read the old priority.

      (Question #2) How can I update message properties in the QueueBrowser  scope?

       

      Thanks

      Laura

        • 1. Re: Some questions about QueueBrowsers
          gaohoward

          Hi,

           

          Q1

          The queue browser in hornetq take a 'snapshot' of the queue's internal delivering list. Scheduled messages are not put in the list until they are due for delivery. That's why you can't see them with browsers.

          You can use the management APIs to access the queue, for example, take a look at QueueControl interface.

           

          Q2

          The setJMSPriority() is for JMS providers, not for users. The priority of a message can be set by users through one of the MessageProducer's send methods:

           

          public void send(Message message,

            int deliveryMode,

            int priority,

            long timeToLive)

           

          Howard

          1 of 1 people found this helpful
          • 2. Re: Some questions about QueueBrowsers
            lauradp

            Hi,

            can a QueueBrowser remove a message from a queue (or instantiate a synchronous consumer in order to remove a message  with a given id)?

             

            I succeeded in using JMSQueueControl, is there any way to obtain it without using JMX?

             

            UPDATE: JMSQueueControl behaves as Queue browser whie messageConsumers are turned on!

            Laura

            • 3. Re: Some questions about QueueBrowsers
              lauradp

              Hi,

              I succeeded in using JMSQueueControl,but I'd like to use management API without connecting to JMX.

               

              JMSQueueControl behaves as QueueBrowser whit messageConsumers are turned on (i.e no message is shown even if message consumer is time consuming). Furthermore JMSQueueControl do not show scheduled messages.

               

              Is there any way to overcome these issues?

               

              Laura

              • 4. Re: Some questions about QueueBrowsers
                jbertram

                JMSQueueControl behaves as QueueBrowser whit messageConsumers are turned on (i.e no message is shown even if message consumer is time consuming).

                This is the expected behavior given the default configuration.  Message consumers retrieve not only the individual message they will consume immediately, but also group of messages which are kept in a client-side buffer.  This is done for performance reasons (read more here).  From the broker's perspective, any message that a client has buffered is not available for any other client (which includes a QueueBrowser).  That's likely why you don't see any messages with your QueueBrowser when consumers are activated. 

                 

                You can tune the size of the client's buffer (see the previously linked doc), and that might allow the QueueBrowser to see more messages even with consumers active.  However, be aware that such adjustments will likely have performance implications.

                 

                Furthermore JMSQueueControl do not show scheduled messages..

                The JMSQueueControl won't list scheduled messages for the same reason that a QueueBrowser won't (which Howard already explained).  There's no way to change this behavior.

                1 of 1 people found this helpful
                • 5. Re: Some questions about QueueBrowsers
                  lauradp

                  How can I change consumer-window-size parameter in JBoss?

                  • 6. Re: Some questions about QueueBrowsers
                    jbertram

                    Check the link from my previous comment.

                    • 7. Re: Some questions about QueueBrowsers
                      lauradp

                      I read the link in the prvious comment, but I cannot find any configuration file about queues (except for standalone.xml).

                       

                      Is there any api for browsing scheduled messages??

                       

                      Laura

                      • 8. Re: Some questions about QueueBrowsers
                        jbertram

                        I read the link in the prvious comment, but I cannot find any configuration file about queues (except for standalone.xml).

                        I'm confused.  What do you need to configure on a queue?

                        • 9. Re: Some questions about QueueBrowsers
                          lauradp

                          I'd  like to set consumer-window-size to 0 in order to disable client side cache.

                           

                          By the way I'm more interested in browsing scheduled messages.

                           

                          Laura

                          • 10. Re: Some questions about QueueBrowsers
                            jbertram

                            I'd  like to set consumer-window-size to 0 in order to disable client side cache.

                            The consumer-window-size is not set on the queue.  It's set on the connection factory that the client uses (if using JMS) or via the core API.  This is all explained in the documentation I linked.  I'm not sure how you missed it.

                             

                            Scheduled messages aren't available for browsing as they aren't technically on the queue until they are put there to actually be delivered.  This is what Howard explained in his first comment.

                            • 11. Re: Some questions about QueueBrowsers
                              lauradp

                              I read about QueueControl that has listScheduledMessages() method, but I don't know how to get an instance of it.

                               

                              Laura

                               

                              UPDATE:

                              I found the instructions you were talking about, but they deal with HornetQConnectionFactory. How can I sert this parameter if I use javax.jms.ConnectionFactory?

                              • 12. Re: Some questions about QueueBrowsers
                                jbertram

                                I read about QueueControl that has listScheduledMessages() method, but I don't know how to get an instance of it.

                                Weren't you using an instance of JMSQueueControl previously?  You get the two instances in basically the same way just with different class names.  Try looking at the "jmx" example that ships with HornetQ for additional help.

                                 

                                I found the instructions you were talking about, but they deal with HornetQConnectionFactory. How can I sert this parameter if I use javax.jms.ConnectionFactory?

                                Are directly instantiating your JMS connection factory or are you looking it up in JNDI?  The documentation covers the configuration options for both.

                                • 13. Re: Some questions about QueueBrowsers
                                  lauradp

                                  Indeed I was using JMSQueueControl  until I read that QueueControl could list ScheduledMessages.

                                  I suceeded in linsting them, but when I try to change its priority (http://docs.jboss.org/hornetq/2.2.5.Final/api/org/hornetq/api/core/management/QueueControl.html#changeMessagePriority(long, int)) the priority doesn't change (and the method returns false).

                                   

                                   

                                  I was looking for a way to make deliverable a given message (identified by its ID) immediatelly (i.e. removing _HQ_SCHED_DELIVERY from its propeties).

                                   

                                   

                                  Can anyone help me?

                                  • 14. Re: Some questions about QueueBrowsers
                                    jbertram

                                    I suceeded in linsting them, but when I try to change its priority (http://docs.jboss.org/hornetq/2.2.5.Final/api/org/hornetq/api/core/management/QueueControl.html#changeMessagePriority(long, int)) the priority doesn't change (and the method returns false).

                                    org.hornetq.core.management.impl.QueueControlImpl#changeMessagePriority doesn't support changing the priority of a scheduled message, and even if it did that priority wouldn't be relevant until the message was placed on the queue for delivery according to its schedule.  In other words, that wouldn't help you make a scheduled message immediately available for delivery.

                                     

                                    I was looking for a way to make deliverable a given message (identified by its ID) immediatelly (i.e. removing _HQ_SCHED_DELIVERY from its propeties).

                                    I don't believe that is possible.

                                    1 2 Previous Next