Selector and Virtual Topic

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Selector and Virtual Topic

bansalp
Lets say I have topic: VirtualTopic.A and a Queue Consumer.B.VirtualTopic.A,
There are two consumer one subscribing to topic VirtualTopic.A and other on queue Consumer.B.VirtualTopic.A both are using selector?

Will there be any problem because of using selectors?
Will selector make dispatching from queue slow?


--bansalp
Reply | Threaded
Open this post in threaded view
|

Re: Selector and Virtual Topic

Tim Bain
Selectors will make dispatching slightly slow*er*, but will it make it
*slow*?  That depends on your setup, and no one but you will be able to
answer performance questions about your usecase, your configuration, and
your hardware.  Try it and see; that's the only way you're going to know
whether your performance is acceptable; anyone else's experience isn't
going to give you more than a guess as to whether things will be OK for
your particular setup.

With that being said, my guess is that it'll be fine, because the feature
wouldn't have made it into production if it immediately destroyed
performance.  But that's just a guess, because I don't know the details of
your setup.

On Tue, Jan 6, 2015 at 2:02 AM, bansalp <[hidden email]> wrote:

> Lets say I have topic: VirtualTopic.A and a Queue
> Consumer.B.VirtualTopic.A,
> There are two consumer one subscribing to topic VirtualTopic.A and other on
> queue Consumer.B.VirtualTopic.A both are using selector?
>
> Will there be any problem because of using selectors?
> Will selector make dispatching from queue slow?
>
>
> --bansalp
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Selector-and-Virtual-Topic-tp4689544.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Selector and Virtual Topic

artnaseef
That's close.  Selectors can be terrible for performance.

The way ActiveMQ applies selectors is like this:

  ON MESSAGE DISPATCH
    WHILE ( message is NOT dispatched ) AND ( more consumers exist )
       IF selector matches
       THEN
         DISPATCH message
       END IF

The problem for performance comes with large numbers of consumers with distinct selectors.  In this case, dispatch of messages performs on the order of O(n) - for every message - where "n" is the number of consumers.  So, 1000 consumers in a worst-case-scenario will take about 1000 times longer to get through this dispatch loop compared to 1 consumer.

Be careful with selectors.  They have been known to kill performance of a solution.

With that said, the scenario described will work.  The queue and topic subscribers have their own selectors and in no way compete for messages.