<div>
<div>
<span>Toby,</span></div><div><span><br></span></div><div><span>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.</span></div><div><span><br></span></div><div><span>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.</span></div><div><span><br></span></div><div><span>There is another option that you could consider that has _slightly_ different semantics: use a destination such as /exchange/amq.direct/country.australia.</span></div><div><span><br></span></div><div><span>The main difference between /queue and /exchange in this instance is how multiple subscribers are treated.</span></div><div><span><br></span></div><div><span>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.</span></div><div><span><br></span></div><div><span>With /exchange, each subscriber will get a copy of each message. </span></div><div><span><br></span></div><div><span>I'm guessing for your use case that round-robin is probably the most suitable.</span></div><div><span><br></span></div><div><span>Regards,</span></div><div><span><br></span></div><div><span>Rob</span></div><div><br></div><div><span>-- <br>Rob Harrop<br>RabbitMQ<br></span>
<p style="color: #a0a0a0;">On Tuesday, 7 June 2011 at 05:20, Toby Corkindale wrote:</p>
<blockquote type="cite" style="border-left-style:solid;border-width:1px;margin-left:0px;padding-left:10px;">
<span><div><div>Hi,<br>I'm afraid I'm something of a beginner when it comes to message queuing <br>systems, although I've submitted several patches to the Perl STOMP <br>modules in the process of using them recently, and have picked up what I <br>think is a bit of knowledge.<br><br>Anyway, I have a query about RabbitMQ's STOMP plugin, and haven't quite <br>been able to understand the docs on the matter.<br><br>My goal is to have a queue where the consumers of that queue only <br>receive a subset of all messages. I want them to filter based on a <br>header in the messages.<br><br>Eg.<br><br>SEND<br>destination:/queue/foo<br>x-country:australia<br><br>with the receiver somehow doing something like:<br>SUBSCRIBE<br>destination:/queue/foo?x-country=australia<br><br><br>Now currently I can achieve this goal by creating lots of queues, one <br>for each possible value, and then the consumers can subscribe to all the <br>queues.. but this is a bit messy.<br><br>Eg.<br>SEND<br>destination:/queue/foo.australia<br><br>SUBSCRIBE<br>destination:/queue/foo.australia<br><br><br>There are some discussions of routing keys in the STOMP plugin's docs, <br>but I don't understand how they relate. Are they what I'm looking for?<br>I only want this to work with simple queues, not, as far as I know, <br>exchanges. Maybe I'm barking up the wrong tree though?<br><br>I note that in ActiveMQ's STOMP plugin, you can apply a selector to the <br>subscription like this:<br><br>SUBSCRIBE<br>destination:/queue/foo<br>activemq.selector:country="australia"<br><br><br>Thanks,<br>Toby<br>_______________________________________________<br>rabbitmq-discuss mailing list<br><a href="mailto:rabbitmq-discuss@lists.rabbitmq.com">rabbitmq-discuss@lists.rabbitmq.com</a><br><a href="https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss">https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss</a><br></div></div></span>
</blockquote>
<div>
<br>
</div>
</div>
</div>