Eduard Grinberg
Eduard Grinberg

Reputation: 337

RabbitMQ: Is message duplicated when routed from RabbitMq exchange to each queue

In RabbitMQ, If I have an exchange and two queues bound to it with same routing key for example "rk1*", how many copies of the message will be physically stored in Rabbit?

More generally, does Rabbit store separate copy of message for each queue?

Upvotes: 2

Views: 1698

Answers (2)

Eduard Grinberg
Eduard Grinberg

Reputation: 337

I inspected the file system and I found that message is copied, at least on disk, for every queue.

I've created Durable Topic exchange and 2 queues bound to it with same routing key.

This is how directory structure looks like: enter image description here

When I publish message to the exchange, I can see it's text in the .idx file for each queue: enter image description here

So I guess this answers my question. Hope it helps.

Upvotes: 2

Rajan Prasad
Rajan Prasad

Reputation: 1679

It really depends on what kind of exchange you have? Do you have a direct exchange, a topic exchange, or a fanout exchange.

Here is more on RabbitMq architecture.

Here is some working demo code for setting up a fanout exchange.

Upvotes: 1

Related Questions