[rabbitmq-discuss] Cluster behavior with distributing messages internally over Wide area networks

Alexandru Scvorţov alexandru at rabbitmq.com
Wed Aug 18 11:53:22 BST 2010


> > I was wondering whether a Node is aware of what to and what not to deliver to a cluster peer. 
> > 
> > Eg.
> >    
> > Producer
> >    \/
> > [Node 1] ===> consumer1 (queue1)
> >    |
> >    | WAN 
> >    |
> > [Node 2] ===> consumer2 (queue2)
> > 
> > Here all messages to will traverse the WAN connection b/c they are delivered to Queue2.
> > 
> > If Node 2 would not have a consumer2, would Node 1 send all it's messages, or will it filter messages only to match a queue in Node2?
> 
> Messages are only sent across the network when they're requested.  So,
> unless something on Node 2 tries to consume messages from queue1, those
> messages will not be sent over the network.
> 
> > I guess my question is rather related to where a queue is held in memory and how it's accessed, 
> 
> A queue is only stored on the node it was declared on.  Within the cluster,
> all nodes can access all queues, but messages are only routed to other
> nodes on-demand.

That's how consuming works.

In a cluster, publishing goes something like this:

>       Producer
>          \/
>        Node 1
>      (exchange)
>         /|\
>        / | \
>       /  |  \
>      /   |   \
> Node 2 Node 3  Node 4
>   Q1    Q2      Q3
>                 Q4

If your producer is publishes a message to an exchange on Node 1 and
there are queues bound to that exchange on nodes 2, 3, and 4, the
message is sent from Node 1 to the other Nodes only if the queue
bindings match (it doesn't broadcast them).  If there are multiple
matching queues on a node (e.g. Node 4 has Q3 and Q4), the message
is only sent once from Node 1 to Node 4.

Alex


More information about the rabbitmq-discuss mailing list