Topic Exchange vs Direct Exchange in RabbitMQ

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

    Assuming both models are being considered to be implemented using one broker running, there's little difference that I can see.

    Option 2 seems more common in the real world for solving this kind of routing problem (at least in my anecdotal experience) and it's exactly the challenge that Topic Exchanges exist to solve.

    The only difference that you might encounter would relate to routing speed. I don't know for sure if Exchange routing (based always on an exact string match) is faster in RabbitMQ when compared to the routing key technique used in Topic Exchanges (which can include wildcards like # and *). My hunch would be that Exchange discrimination would be faster, but you could experiment for yourself to find out, or try contacting the RabbitMQ team to ask them.

    Finally, if you go with option 1 end up with lots of queues then you'll have a proportional proliferation of Exchanges. That sounds like a maintenance headache. If you'll only have a handful of queues then it won't be too much of an issue.

提交回复
热议问题