[rabbitmq-discuss] Understanding the topic exchange behavior

Michael Klishin mklishin at gopivotal.com
Thu Apr 17 09:25:15 BST 2014


On 17 April 2014 at 12:17:27, spicoflorin at gmail.com (spicoflorin at gmail.com) wrote:
> >
> Suppose that you have:
>  
>  
> - a producer that is sending messages using routing key "kern.critical"  
>  
>  
> -two consumers that are consuming using the same routing key  
> "kern.critical".
>  
>  
> In my understanding, the behavior for this case should be, that  
> the consumers will consume in a round robin fashion messages  
> (direct exchange). In reality, both consumers will receive  
> the same sent messages, and that is not the case of direct exchange  
> contract.
>  
>  
> 1. Is this an issue of the documentation or my understanding is  
> wrong?

You are confusing *routing* and consumption. Routing keys used by queue.bind
are used to distribute messages between queues. Then consumers consume them
in the round robin fashion (given that both use channels with qos = 1).

It’s true that direct exchange can route a message to multiple queues.

> 2. When using the topic exchange, all the consumers that are listening  
> to a specific bounded queue will receive the same messages. In  
> the given example from the tutorial, if Q1 has two consumers,  
> then both of them will receive same sent messages.

If a queue has two consumers, they *will not* receive the same message.

Again, you are confusing routing and consumption See [1].

1. http://www.rabbitmq.com/tutorials/amqp-concepts.html 
--  
MK  

Software Engineer, Pivotal/RabbitMQ


More information about the rabbitmq-discuss mailing list