[rabbitmq-discuss] Fetching messages from exchange once I connect

Michael Klishin mklishin at gopivotal.com
Sun Oct 13 13:20:06 BST 2013


On 13 Oct 2013, at 14:49, tyger2007 at yahoo.com wrote:

> I am using rabbitmq for an application , I have an exchange to exchange binding like this 
> Clientapp1 connects to rabbitmq server creates a fanout exchange and binds it to an exchange ( post exchange that is always on the server ) this is more like an exchange to exchange binding so another consumer can always try to read from a central exchange instead of binding to all the exchanges he subscribed to , I have two questions based on this implementation 
> 1)since the central exchange(post exchange) is a topic exchange on the server with multiple clientapps binding their exchange to it  , how do I route the messages effectively to consumers that have queues bound to the post exchange based on their binding keys

Sorry but consumers do not consume from exchanges. They consume from queues which
exchanges route messages to.

See http://www.rabbitmq.com/tutorials/amqp-concepts.html if you need a brief intro
to the concepts.

> 2)if consumer3  was not alive when the message was sent to post exchange , how does the app fetch all the sent messages once he connects to the server .

Again, consumers don't know anything about exchanges.

If a message is published to an exchange X, then one of the following scenarios
occurs:

 * X has queues bound to it with matching routing keys. A copy of the message is placed into each queue.
 * X has no bindings or none with matching routing keys. The message will either be sent to
   an alternate exchange (if any) or returned to the publisher (if published as mandatory) or voided.
 * X has exchanges bound to it. Then it works as if a copy of the message was published to every
    one of those exchanges (with matching routing keys).

Note that exchange-to-exchange bindings are relatively rarely used by applications.

Now, if a message is routed to a queue that has no consumers, it will sit there waiting for
a consumer to come around or an app pull messages using basic.get. Whether messages
survive RabbitMQ node restart depends on queue durability and if messages are
published as persistent but otherwise, the message will sit there waiting to be consumed.

MK





More information about the rabbitmq-discuss mailing list