5

I've been trying to use RabbitMQ and faced the following question (very similar to this one: Topic Exchange vs Direct Exchange in RabbitMQ).

I need to intensively broadcast something around 800 types of messages (so there will be many consumers for each message type) and I wonder which of the following approaches is better:

  1. Create one direct exchange where messages will be sent with a routing key (message type name) and every consumer will be connected to it with a temporary queue bound with a corresponding routing key. (Because there is no complex routing keys like 'key1.key2.*' I decided not to use topic exchange).

  2. Create a fanout exchange for each message type.

I've read very good article about performance issues - ROUTING TOPOLOGIES FOR PERFORMANCE AND SCALABILITY WITH RABBITMQ but I'm new to RabbitMQ and just want to get some more best practices advice.

Community
  • 1
  • 1
Teddy Bo
  • 679
  • 8
  • 19

1 Answers1

-3

Go with the routing key, it will be simpler and more efficient :)

C4stor
  • 8,355
  • 6
  • 29
  • 47
  • 2
    I do not see why it is more efficient or simpler. If you have any arguments I'll be glad to know them. My own research has shown that fanouts work a little bit faster. – Teddy Bo Jun 17 '13 at 13:55
  • The fanout are a durable construction. If you have 800 types of messages, I guess some are appearing, some are disappearing. You'll need to clean manually unused fanouts, and create new ones when that happens. On the other end with direct queues binding, each client is responsible for knowing what messages he's interested on, and the queues he create can live only while the client is alive, which ensures only useful elements are created on rabbit. – C4stor Jun 17 '13 at 14:08
  • Thanks for your reply. In my case I know for sure that all types of messages are constantly used so there is no need to delete fanout exchanges (btw I didn't notice that number of existing unused exchanges make any load on a server). And temporary queues created by clients is killed in both cases. – Teddy Bo Jun 17 '13 at 20:23
  • Does it matter what queue gets what type of message? – Brandon Raeder Apr 23 '21 at 10:14