Topic Exchange vs Direct Exchange in RabbitMQ

前端 未结 5 2263
再見小時候
再見小時候 2021-01-30 06:53

We\'ve got an application which will be using RabbitMQ and have several different queues for passing messages between tiers.

Initially, I was planning to use multiple di

5条回答
  •  感动是毒
    2021-01-30 07:05

    Indeed approach 2 is better as it gives you flexibility to use a single queue for multiple routing keys.

    Exchange Topic

    QueueA-- binding key = India.Karnataka.*
    

    You can route a message to topic exchange with routing key as India.Karnataka.bangalore,India.Karnataka.Mysore.

    All the above messages goes to QueueA.

    Direct Exchange

    But I did not understand on why are you creating multiple direct exchanges in approach 1. You can have single direct exchange and have multiple queues with each queue binding with a unique key.

    QueueA-- binding key = Key1
    QueueB-- binding Key = Key2
    QueueC-- binding Key = Key3
    

    All key1 messages goes to QueueA.Key2 goes to QueueB ... You can still maintain single direct exchange.

提交回复
热议问题