Version 3

    Why do I get slow performance when I use message selectors with contested queues.


    NOTE: This question only applies to Queues, Topics are not contested and do their selection at message send time, not receive.


    Simple Answer:

    Because JMS is not an RDMS


    Longer Answer:

    When you run the message selector it will use "read and skip", the queue is not indexed like a database table.


    It will start at the first message in the queue and check each individually to see whether it matches the selector. It has to do this for every receive()


    If few (or even worse none) match the selector, it will have to check lots (all) of messages. This will be especially bad when messages towards the bottom of the queue are not in memory, meaning it has to load the message into memory to look at the properties.



    Task to provide an "index" over queues in JBossMQ