Selective routing with RabbitMQ

≯℡__Kan透↙ 提交于 2019-12-10 17:47:13

问题


I have some queues bound to one topic exchange, e.g. with routing keys:

1) big.yellow.rabbit
2) small.*.dog
3) small.*.*
4) *.*.cat
5) *.*.*

I want the RabbitMQ to choose only one queue to place my message by following logic:

  • the number of coincident tags should be as big as possible
  • coincidence of first tag is more importat than for second...

Examples for aforementioned keys:

big.yellow.rabbit -> 1) 
small.yellow.rabbit -> 3) 
small.white.cat -> 3)
big.grey.cat -> 4)
big.yellow.pig -> 5)

I've come to conclusion that common exchange types (direct, topic, fanout, headers) will not help me. And I need to implement new custom type. Am I right?

Thanks.


回答1:


Yes, the routing logic you describe is not implemented by any of the default exchange types in RabbitMQ; you'll have to write your own.

You'll need to write a RabbitMQ plugin. More concretely, you'll need to write a custom exchange type: you can find a bunch of examples on the Developer Tools page.

If you need any pointers on how to get started or get stuck, post a question on the RabbitMQ-Discuss mailing list. The RabbitMQ developers read that list and make a point of not leaving any questions unanswered.



来源:https://stackoverflow.com/questions/9966354/selective-routing-with-rabbitmq

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!