activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bain <>
Subject Re: destination unspecified - can ActiveMQ set it?
Date Tue, 02 May 2017 12:59:41 GMT
Selectors are a way for a consumer to tell the broker, "Don't send me
messages like this when you do normal dispatch for this destination."

For a queue, all messages are essentially communal between the set of
consumers, so the skipped messages stay on the queue for some other
consumer (one with a matching selector) to consume them. It's very
important that you ensure that the set of selectors from the different
consumers covers all messages that will be sent, because any messages that
don't match any consumer will sit on the top of the queue and if there are
enough of them they can prevent messages from being dispatched to any
consumer and work will stop on the queue.

For a topic, each consumer has their own copy of the message stream, so
messages that don't match their consumer's selector are simply discarded
rather than left behind. This means it's not critical to ensure that the
set of selectors fully covers the set of messages.

So yes, they're specified by the consumers, but they will have their
desired effect even though they haven't been specified when the first
message is sent.

As long as your routing rules can be computed at consumer startup (i.e.
there's nothing dependent on application state), selectors could give you
what you need in the more-limited scenarios you described.

One caution, though: Art Naseef always warned that selectors were an easy
way to kill broker performance, because they must be evaluated on the
broker for each message for each consumer. So if you are going to have
large numbers of consumers and/or large numbers of messages (and
unfortunately I don't have good heuristics for what constitutes "large
numbers" here), there might be a performance impact to using the selector
approach. With that said, lots of people use selectors in ActiveMQ without
performance problems, so if you think, "we don't have all THAT many
messages and consumers," you'll probably be fine.


On May 2, 2017 3:54 AM, "Vince Cole" <> wrote:

> Hi Tim
> OK - just one more question:
> If having a single consumer per queue wasn't a problem, would Selectors
> still be a workable solution?
> Or can they only be used if you have consumers (i.e. is it the consumers
> who
> have to specify them)?
> OK OK - another:
> If it was OK to lose messages when consumers weren't attached, then topics
> could be used.
> Would Selectors work in the same way with topics?
> thanks again in advance
> --
> View this message in context: http://activemq.2283324.n4.
> it-tp4725338p4725420.html
> Sent from the ActiveMQ - User mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message