[rabbitmq-discuss] STOMP - Message queue selectors for consumers?

Rob Harrop rob at rabbitmq.com
Tue Jun 7 12:30:51 BST 2011


Toby,

The solution you propose is the easiest and most efficient way of doing it on RabbitMQ STOMP. Using different /queue/ destinations removes the need for complex matching during message routing.

Queues are cheap in RabbitMQ and each /queue corresponds to one queue, so creating a queue per country is not expensive. Also, queues are created lazily so you don't need to worry about ordering consumers/publishers.

There is another option that you could consider that has _slightly_ different semantics: use a destination such as /exchange/amq.direct/country.australia.

The main difference between /queue and /exchange in this instance is how multiple subscribers are treated.

With /queue, if you have two subscribers to the same country queue, then messages are sent out to the consumers in a round-robin fashion.

With /exchange, each subscriber will get a copy of each message. 

I'm guessing for your use case that round-robin is probably the most suitable.

Regards,

Rob

-- 
Rob Harrop
RabbitMQ

On Tuesday, 7 June 2011 at 05:20, Toby Corkindale wrote:

> Hi,
> I'm afraid I'm something of a beginner when it comes to message queuing 
> systems, although I've submitted several patches to the Perl STOMP 
> modules in the process of using them recently, and have picked up what I 
> think is a bit of knowledge.
> 
> Anyway, I have a query about RabbitMQ's STOMP plugin, and haven't quite 
> been able to understand the docs on the matter.
> 
> My goal is to have a queue where the consumers of that queue only 
> receive a subset of all messages. I want them to filter based on a 
> header in the messages.
> 
> Eg.
> 
> SEND
> destination:/queue/foo
> x-country:australia
> 
> with the receiver somehow doing something like:
> SUBSCRIBE
> destination:/queue/foo?x-country=australia
> 
> 
> Now currently I can achieve this goal by creating lots of queues, one 
> for each possible value, and then the consumers can subscribe to all the 
> queues.. but this is a bit messy.
> 
> Eg.
> SEND
> destination:/queue/foo.australia
> 
> SUBSCRIBE
> destination:/queue/foo.australia
> 
> 
> There are some discussions of routing keys in the STOMP plugin's docs, 
> but I don't understand how they relate. Are they what I'm looking for?
> I only want this to work with simple queues, not, as far as I know, 
> exchanges. Maybe I'm barking up the wrong tree though?
> 
> I note that in ActiveMQ's STOMP plugin, you can apply a selector to the 
> subscription like this:
> 
> SUBSCRIBE
> destination:/queue/foo
> activemq.selector:country="australia"
> 
> 
> Thanks,
> Toby
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com (mailto:rabbitmq-discuss at lists.rabbitmq.com)
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110607/d0a9fd59/attachment.htm>


More information about the rabbitmq-discuss mailing list