Topic Exchange vs Direct Exchange in RabbitMQ

前端 未结 5 2163
再見小時候
再見小時候 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:20

    One thing that should also be considered is, that your code for publishing the messages will look slightly different when you publish to different exchanges vs. when you publish to a single exchange but only with different routing keys.

    Keep in mind that your code needs to know the names of the different exchanges from somewhere (probably from configuration) and you have to maintain kind of a mapping between exchanges and routing keys. Also with direct exchanges in RabbitMQ, the routing key needs to exactly match the queue names. So your code then needs to know the queue names too to be able to set the correct routing keys.

    When using a single exchange (no matter if direct or topic) your code only needs to deal with one exchange and the routing keys.

提交回复
热议问题