Persistent message and selectors

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

Persistent message and selectors

bansalp
Hi,

Two cases here:

Topic:
Producer is sending persistent message to a topic "A" and subscriber has subscribed using selector on topic "A" (durable subscription). Now will all message send on "A" get stored in persistent store or only message which matches selector criteria get stored?

Queue:
Producer is sending persistent message to a queue "B" and consumer is consuming using selector on queue "B". Now will all message send on "B" get stored in persistent store or only message which matches selector criteria get stored?

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

Re: Persistent message and selectors

Tim Bain
For queues, all messages will be stored, irrespective of whether there is
currently a consumer for them.  That's how queues work.

For topics, I expect that the message would be discarded (topic messages
are delivered to all applicable subscribers, of which there are zero in
this case), but I don't know for sure.  But it would be really easy for you
to test this; set up your consumer, produce a single message (and make sure
no other process is publishing to that topic), and then attach JConsole to
the broker and navigate to that topic's JMX information in the MBeans tab
and look at the topic's attributes.  If you see a MemoryUsageByteCount of 0
then the message was discarded, and if it's non-zero then it wasn't.

If you haven't already, get to know the JMX information available in
JConsole; it's really useful for seeing how the broker behaves, and would
let you answer questions like these without needing to ask for help.

On Mon, Jan 5, 2015 at 11:45 PM, bansalp <[hidden email]> wrote:

> Hi,
>
> Two cases here:
>
> *Topic:*
> Producer is sending persistent message to a topic "A" and subscriber has
> subscribed using selector on topic "A" (durable subscription). Now will all
> message send on "A" get stored in persistent store or only message which
> matches selector criteria get stored?
>
> *Queue:*
> Producer is sending persistent message to a queue "B" and consumer is
> consuming using selector on queue "B". Now will all message send on "B" get
> stored in persistent store or only message which matches selector criteria
> get stored?
>
> Thanks,
> --bansalp
>
>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/Persistent-message-and-selectors-tp4689542.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>
Reply | Threaded
Open this post in threaded view
|

Re: Persistent message and selectors

artnaseef
For Queues, that's right - all messages are stored until consumed (once and only once consumption).

For Topics, it's a little more complicated.  It's easiest to think of it this way: topics never store messages themselves; topic subscriptions may store messages.  Durable subscriptions do store messages for the obvious reason (need to deliver to the durable subscriber across broker restarts).  And, since the only messages that go to a subscription are those that match its selector, those would be the only ones stored.

With that said, durable subscriptions tend to lead to many problems, so please use them with care.  Any part of the system that relies on a very specific consumer being active can easily run into slow consumption problems.  Selectors with Queues also tend to be similarly problematic when messages that do not match any consumer's selector are sitting around (they also perform poorly with large numbers of consumers because they are evaluated in order against every consumer until a match is found).  Camel is a good tool for handling patterns in which selectors are desirable.