Selective routing with RabbitMQ

I have multiple queues associated with one topic exchange, for example. with routing keys:

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

      

I want RabbitMQ to select only one queue to host my message, following the logic:

  • the number of matching tags should be as large as possible
  • match the first tag is more importat than the second ...

Examples for the above 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 the conclusion that the usual exchange types (straight, threads, forks, headers) won't help me. And I need to implement a new custom type. I'm right?

Thank.

+3


source to share


1 answer


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

You need to write a RabbitMQ plugin . More specifically, you need to write your own type of exchange: you can find a bunch of examples on the Developer Tools page .



If you need pointers on how to get started or get stuck, please post a question on the RabbitMQ-Discuss mailing list . RabbitMQ devs read this list and leave any unanswered questions unanswered.

+6


source







All Articles