Topic exchange question: multiple queues with same routing key?

1,246 views
Skip to first unread message

Sandy Walsh

unread,
Feb 4, 2015, 4:41:25 PM2/4/15
to rabbitm...@googlegroups.com
Hey y'all,

Hopefully this is a simple question.

We have Exchange A bound to Queue B via Routing key C. 

I create a new Queue X, bound to Exchange A with routing key C as well. 

I expect to get messages in B and X, but I only get them in B. 

(messages are sent to exchange A with routing key C

So, 

Exchange A -> (routing key C) -> Queue B ... gets messages
                   -> (routing key C) -> Queue X ... gets no messages

Suggestions?





Sandy Walsh

unread,
Feb 4, 2015, 6:13:58 PM2/4/15
to rabbitm...@googlegroups.com
nm, found it. 

Turns out we were publishing to the "nameless" exchange. And the routing semantics are different there. In that case, the routing_key is the target queue. 

rabbitmq

unread,
Feb 4, 2015, 6:14:18 PM2/4/15
to rabbitm...@googlegroups.com
I find this statement confusing:


"I create a new Queue X, bound to Exchange A with routing key C as well. "

So I'm not sure if I understand correctly, but I am pretty sure you need to define a new "routing key D" to match messages and put them in "queue X"

Sandy Walsh

unread,
Feb 4, 2015, 6:25:43 PM2/4/15
to rabbitm...@googlegroups.com
Sorry, take out "as well"

Michael Klishin

unread,
Feb 4, 2015, 11:40:20 PM2/4/15
to rabbitm...@googlegroups.com, Sandy Walsh
 On 5 February 2015 at 00:41:27, Sandy Walsh (sa...@sandywalsh.com) wrote:
> We have Exchange A bound to Queue B via Routing key C.
>
> I create a new Queue X, bound to Exchange A with routing key C as
> well.
>
> I expect to get messages in B and X, but I only get them in B.
>
> (messages are sent to exchange A with routing key C
>
> So,
>
> Exchange A -> (routing key C) -> Queue B ... gets messages
> -> (routing key C) -> Queue X ... gets no messages
>
> Suggestions?

This is how it should work for direct exchanges. However, this is a tricky
case for default exchange ("") and the spec doesn't really say how things
should be routed.

If you need to deliver to N queues, I'd generally recommend using topics or fanouts.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

Alvaro Videla

unread,
Feb 5, 2015, 5:07:11 AM2/5/15
to Michael Klishin, rabbitm...@googlegroups.com, Sandy Walsh
What I don't understand is how you were first creating queues and binding them to Exchange A, but then you were publishing messages to the default exchange (""), since binding to the default exchange is not allowed, it would have resulted in a protocol error.

So something in the code must have a bug where the exchange name was reset to ""  when publishing?

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send an email to rabbitmq-users@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sandy Walsh

unread,
Feb 5, 2015, 10:01:03 AM2/5/15
to rabbitm...@googlegroups.com, mkli...@pivotal.io, sa...@sandywalsh.com
I didn't bind to the default exchange, only the named ones. But I was publishing to the nameless exchange unknowingly. 

Kombu accepts "exchange" as a optional parameter, defaulting to the nameless exchange. 

Problem is, I didn't know this nameless exchange was even a thing, let alone the special route handling. Quite confusing. 



On Thursday, February 5, 2015 at 6:07:11 AM UTC-4, Alvaro Videla wrote:
What I don't understand is how you were first creating queues and binding them to Exchange A, but then you were publishing messages to the default exchange (""), since binding to the default exchange is not allowed, it would have resulted in a protocol error.

So something in the code must have a bug where the exchange name was reset to ""  when publishing?

On Thu Feb 05 2015 at 5:40:18 AM Michael Klishin <mkli...@pivotal.io> wrote:
 On 5 February 2015 at 00:41:27, Sandy Walsh (sa...@sandywalsh.com) wrote:
> We have Exchange A bound to Queue B via Routing key C.
>
> I create a new Queue X, bound to Exchange A with routing key C as
> well.
>
> I expect to get messages in B and X, but I only get them in B.
>
> (messages are sent to exchange A with routing key C
>
> So,
>
> Exchange A -> (routing key C) -> Queue B ... gets messages
> -> (routing key C) -> Queue X ... gets no messages
>
> Suggestions?

This is how it should work for direct exchanges. However, this is a tricky
case for default exchange ("") and the spec doesn't really say how things
should be routed.

If you need to deliver to N queues, I'd generally recommend using topics or fanouts.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ

--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send an email to rabbitm...@googlegroups.com.

Michael Klishin

unread,
Feb 5, 2015, 10:05:57 AM2/5/15
to rabbitm...@googlegroups.com, Sandy Walsh
 On 5 February 2015 at 18:01:03, Sandy Walsh (sa...@sandywalsh.com) wrote:
> Kombu accepts "exchange" as a optional parameter, defaulting
> to the nameless exchange.
>
> Problem is, I didn't know this nameless exchange was even a thing,
> let alone the special route handling. Quite confusing.

Sandy,

Any particular reason why you decided to use Kombu? It's a decent client but also
quite opinionated. Our tutorials use Pika, please take a look: http://www.rabbitmq.com/getstarted.html.

We also have a concept guide which is a couple of pages. Highly recommended ;)
 http://www.rabbitmq.com/tutorials/amqp-concepts.html

Sandy Walsh

unread,
Feb 5, 2015, 11:52:23 AM2/5/15
to rabbitm...@googlegroups.com, sa...@sandywalsh.com


On Thursday, February 5, 2015 at 11:05:57 AM UTC-4, Michael Klishin wrote:
 On 5 February 2015 at 18:01:03, Sandy Walsh (sa...@sandywalsh.com) wrote:
> Kombu accepts "exchange" as a optional parameter, defaulting  
> to the nameless exchange.
>  
> Problem is, I didn't know this nameless exchange was even a thing,  
> let alone the special route handling. Quite confusing.

Sandy,

Any particular reason why you decided to use Kombu? It's a decent client but also
quite opinionated. Our tutorials use Pika, please take a look: http://www.rabbitmq.com/getstarted.html.


Legacy things (openstack) ... we should really convert. I agree their abstractions are a little arbitrary. 

 
We also have a concept guide which is a couple of pages. Highly recommended ;)
 http://www.rabbitmq.com/tutorials/amqp-concepts.html

Yeah, missed that part :)

Thanks
Reply all
Reply to author
Forward
0 new messages