[rabbitmq-discuss] question regarding topic routes

Matthias Radestock matthias at rabbitmq.com
Fri Dec 28 16:35:03 GMT 2012


On 28/12/12 16:28, Alvaro Videla wrote:
> How is the '#' meant to be used in binding keys?
> Actually, what happens when I have the following binding:
> #.some.topic.words ?
> Then I sent messages with the following routing keys:
> - here.are.some.topic.words <--- matches
> - here.some.topic.words <--- matches
> - here.topic.words <-- doesn't match?
> Does this mean that the three last words of my binding have to be
> 'some', 'topic' and 'words' but it doesn't matter how many words are
> there in front?

Correct. From s3.1.3.3 of the AMQP 0-9-1 spec:

The routing key used for a topic exchange MUST consist of zero or more 
words delimited by dots. Each word may contain the letters A-Z and a-z 
and digits 0-9. [NB: rabbit doesn't enforce this]. The routing pattern 
follows the same rules as the routing key with the addition that * 
matches a single word, and # matches zero or more words. Thus the 
routing pattern *.stock.# matches the routing keys usd.stock and 
eur.stock.db but not stock.nasdaq.

So there is no restriction on where the * and # can go - beginning, 
middle, end are all fine.

> Is it expected to be used this way

Can't see why not.

> or I should use '*' to represent how many words I want to skip from
> the beginning of the routing key?

If that is possible (it may not be, i.e. an app may want to match on the 
tail w/o knowing how many words there can be in the head) then it is 
likely to be more efficient than using #.



More information about the rabbitmq-discuss mailing list