1 2 Previous Next 24 Replies Latest reply on May 30, 2007 5:16 PM by parressh Go to original post
      • 15. Re: Viewing message contents in a queue
        timfox

         

        "parressh" wrote:
        Would that be a sufficient explanation for how I prevent messages from being consumed by the MDB before I browse them?

        Thanks


        That's not what I meant.

        You said that you could see no messages in your queue if you attached an MDB to it.

        If you attach an MDB to the queue, how do you know that the MDB hasn't just consumed the messages in the queue, and that is why you cannot see them when browsing?

        That's why I asked how are you preventing the MDB from consuming the messages so you would expect them to still be in the queue.

        • 16. Re: Viewing message contents in a queue
          timfox

          If you could explain to me *exactly* what you did to see the issue that would be the best way to handle this.

          Imagine I am an idiot (it won't take much stretch of the imagination).

          Then you:

          1) Deployed MDB consuming from queue A

          2) Sent 20 messages to queue A from a jms client

          3) Browsed queue A - oops! I can't see any messages

          Something like the above would be great.

          (My previous question was how do you know that MDB just hasn't consumed the messages between 2) and 3) )

          • 17. Re: Viewing message contents in a queue
            parressh

            Okay, maybe I wasn't asking the question very well before. My question to you is, how do I configure an MDB to not consume all the messages on a queue? This is the question I thought you were answering when you recommended setting the PrefetchSize variable. So, now that the correct question has been stated, do you know of an answer? Otherwise, is there any other way to see the messages when there is an MDB attached?

            You example steps to reproduce the issue are exactly what I was doing. It appeared to me that the MDB was only consuming 1 message at a time. But it seems that the QueueBrowser is showing that a message is never just sitting on the queue waiting for the consumer to consume it.

            • 18. Re: Viewing message contents in a queue
              timfox

              As I mentioned before, the message consumer will prefetch messages from a queue.

              So if you add 20 messages to the queue and have a consumer they will all be prefetched into the consumer, so they are no longer on the queue to be browsed.

              So in your "step by step", not seeing messages in the queue is expected behaviour.

              • 19. Re: Viewing message contents in a queue
                parressh

                Okay, so there is no way to use a QueueBrowser when an MDB is attached? If not, I suppose I'll rip out the MDB and create my own pool of listeners in separate threads. Then I could have the listeners only consume a specified number of messages, right? Also, if I do it this way, would the RedeliveryDelay value specified in the jbm config start working properly? If you remember from another thread, when using MDB's, the RedeliveryDelay property has no meaning.

                • 20. Re: Viewing message contents in a queue
                  timfox

                  You can use a QueueBrowser if an MDB is attached, it's just that you will only see those messages that are on the queue.

                  Exactly the same applies whether you're using an MDB or any other consumer.

                  The prefetch size determines how many messages will be prefetched.

                  • 21. Re: Viewing message contents in a queue
                    timfox

                    As I also mentioned before, do not use QueueBrowsers if you want them to reflect exact snapshot of what is in the queue, this is not what they were designed for.

                    The JMS spec is quite clear about this.

                    • 22. Re: Viewing message contents in a queue
                      timfox

                      I will do a quick verification to see if there is a problem here before I cut the next release, but I doubt I'll see anything unexpected.

                      • 23. Re: Viewing message contents in a queue
                        timfox

                        Ok I have performed a simple test.

                        I deployed an MDB that just sleeps for 24 hours when it receives a message.

                        I deployed that MDB in JBAS 4.2.0 consuming from queue queue/testQueue

                        I then wrote a simple client program that sent 2000 messages to testQueue.

                        I think waited 2 seconds before immediately browsing that queue and counting the messages.

                        Results were that 1834 messages left in the queue.

                        I am using all the default settings in JBAS and JBM.

                        If you consider that default prefetch size is 150, and the default MDB container will instantiate 15 MDB instances, each with a message buffer of 1 (also configurable).

                        Then I would expect 150 + 15 * 1 + 1 = 166 messages to not be in the queue (the last one is the one we actually consumed before sleeping).

                        Note that 2000 - 166 = 1834 *exactly*. So we have exactly accounted for the all the messages.

                        As I said before if you want to reduce the amount that are buffered you can reduce the prefetchSize, but be wary of any performance implications.

                        You could also reduce the MDB pool size to less than 15.

                        • 24. Re: Viewing message contents in a queue
                          parressh

                          Okay, I think I figured out the problem. I was setting the PrefetchSize value on the ConnectionFactory mbean, but not on the NonClusteredConnectionFactory mbean. However, the MDB is configured to use the java:/JmsXA JNDI name which uses java:/DefaultJMSProvider which connects to java:/NonClusteredXAConnectionFactory which is the other mbean. I hope I have that right, 'cause it isn't easy to follow.

                          Now that I'm setting the PrefetchSize value on both connection factories, I'm seeing all (minus 1) the messages in the browser. Before I couldn't see the first 150 messages (the default PrefetchSize).

                          Tim, thanks for all your help.

                          1 2 Previous Next