[rabbitmq-discuss] Exchange/queue setup question

Francesco Mazzoli francesco at rabbitmq.com
Tue Aug 21 12:11:14 BST 2012


Hi Chris,

At Mon, 20 Aug 2012 12:10:58 -0400,
Chris Johnson wrote:
> I need a second pair of eyes on a small RMQ app I'm working on.
> I suspect the issue I'm seeing is related to how I am defining my exchanges
> and queues.
> 
> If I connect with two clients, I'll see every other message appear on my
> client. If I connect with three clients, I see every third message, and so on.
> In other words, it appears to 1) be deleting every message that gets produced
> on consumption, and 2) round robins which consumer gets each message.
> 
> What I want to see is all clients get the same message each time one is
> posted.
> 
> Is a topic approach the best approach for this, or is fanout the better way to
> handle this?

Rabbit will deliver each message to one consumer only.  So the solution to this
problem is to use multiple queues, possibly with a fanout exchange.

> Here's the specifics of how my producer and consumer is set up:
> 
> PRODUCER (client=bunny)
> =====================
> 
> @topic_exchange ||= client.exchange("internal.platformalert", :type => :topic,
>                                     :durable => true, :autodelete => false)
> @queue ||= client.queue("internal.platformalert.#", :durable => true,
>                         :autodelete => false, :arguments => {'x-ha-policy' => 'all'})
> queue.bind(e, :key => "alert")
> exchange.publish(message, :key => "alert", :persistent => true)                        

I think you're confused about how exchanges work.  You seem to be using the
queue name to match topics, while that's not how exchanges work (the binding
defines that). See the tutorial:
<http://www.rabbitmq.com/tutorials/tutorial-five-python.html>.

--
Francesco * Often in error, never in doubt


More information about the rabbitmq-discuss mailing list