7 Replies Latest reply on Jul 31, 2013 4:27 PM by Keven Wang

    Priority of message doesn't really work

    Keven Wang Newbie

      Hi all,

       

       

      i try to use JMS message priority to the most important message consumed first. And i am using MDB. Now, i managed to set the priority, and i found each single thread of MDB consuming message according to priority, but if look at all available threads for this MDB, then they are not by priority.

       

      Here is the concrete example:

       

      I am using EAP 6.0 (Jboss as 7.1.0) which includes Hornetq 2.2.16.Final.  Let's say i have three kinds of messages defined for the same message queue, m1 with priorioty 9, m2 with priority 5 and m3 with priority 0. Then i see there are always 3 threads consuming these msgs like this order: thread1:all m1, then all m2, at the end all m3, thread2: all m1 first, then m3; thread 3 only m3. So you can see that for each thread, message are consumed by priority order. But for all threads, it is not, for example m3 starts to be consumed at beginng by thread3.

       

      Btw, this is the code i send msg. And i use MessageProducer to send message:

       

                ObjectMessage msg = session.createObjectMessage(task);

                producer.send(msg, Message.DEFAULT_DELIVERY_MODE, getPriority(msg), getTimeToLive(msg));

       

       

      Does any one have clue about this issue? Thank you very much!

        • 1. Re: Priority of message doesn't really work
          Clebert Suconic Master

          messages are probably being delivered before you send the newest priority.. meaning you were too late.

           

           

          Try setting up consumerWindowSize to 0 on your connection. maybe you won't pre-fetching and having a better behaviour for what you need.. but it won't be as fast... but maybe that's what you needed.

          • 2. Re: Priority of message doesn't really work
            Keven Wang Newbie

            Thank you for your response, Clebert. But i am not sure if this is the problem. In my application, i do like this to test if priority works: first deplay an app which sends thousands of m1, m2, m3 into queue, but there is no MDB (consumers) in ths app. Then undeploy this app, and deploy another app which only has MDB (consumers), then see the log how msg consumed. SO i am pretty sure when there is consumers, all msg are already in the queue.

             

            But i also think maybe it is a problem related with consumerWindowSize, like msg are allocated first and send to buffer before consumed. I will try with consumerWindowSize = 0. Is there sth else you suggest?

            • 3. Re: Priority of message doesn't really work
              Clebert Suconic Master

              Notice that with MDBs you will have many consumers running it in parallel unless you set the number of consumers to 1.. I forgot th parameter now but that's easy to check (I think).. if not please let me know.

               

              Also: with priorities we do our best to work on priorities. It doesn't work well with paging.. as we do it as we depage.

               

              If not: if you set consumerWndowSinze=0 on the RA it should work... but that will make your application go slower. Usually you don't really need strict priority as we try our best. if something is already on the buffer it will probably be consumed earlier anyways.

               

               

              Also: try the latest version.

              • 4. Re: Priority of message doesn't really work
                Keven Wang Newbie

                Hi Clebert, I tried with your proposal, it works!!! Either set maxSession as 0 or set consumerWIndowSize as 0, it works. Great! Thank you very much!

                 

                Btw, one additional question, when i set maxSession as 15 (default one),but i always see only 3 threads consuming msg, is there some way to increase # of threads?

                • 5. Re: Priority of message doesn't really work
                  Clebert Suconic Master

                  You would probably need to block for some time in order to see threads on a Thread dump. Try adding a small sleep to see if you see many threads blocking. otherwise it may be consuming too fast and you're not being able to see it on the thread dumps?

                   

                  If that's not the case... you should double check the configs.

                   

                   

                  and if that still not the case.. let me know what happened.

                  • 6. Re: Priority of message doesn't really work
                    Clebert Suconic Master

                    BTW: one thing we all agree as messaging developers (I had a talk even with ActiveMQ guys... and eventually with Sun Open MQ guys)... Object message is slow (it will use serialization, and a lot of refactoring because of that.. very verbose protocol), and you will be always stuck in Java.

                     

                    In a near future we are planning to support more clients and any other client outside of Java won't ever be able to read these messages.. keep that in mind.

                    • 7. Re: Priority of message doesn't really work
                      Keven Wang Newbie

                      Actually, i log when onMessage method called in MDB, then i see threads handling each msg, always 3 threads. But yes, the msgs are consumed very fast, but still it is 6500 msg in the queue when i deploy MDB. Regarding objectmsg, yes, i would like to change, that's some legacy code:(