[rabbitmq-discuss] Routing key questions/suggestions

Matthew Sackman matthew at rabbitmq.com
Tue Nov 30 18:06:19 GMT 2010


On Tue, Nov 30, 2010 at 09:43:49AM -0800, Christian Legnitto wrote:
> 1. Why use "." as the routing token separator?

Well, something has to be chosen, and whatever is chosen is going to be
inconvenient for someone. I don't know whether there was some reason to
choose . over anything else.

> Can we make it configurable on the broker?

Well, it's only code. Having had a quick look through, it seems like the
splitting is currently only done at the use point. So I reckon maybe the
only change that's needed is in rabbit_exchange_type_topic.erl, change
the split_topic_key/1 fun to split on whatever you want.

> Can we support sending a magic X-AMQP-ROUTING-SEPERATOR or something
> header with the message so it can be anything and vary by message?

Erm that would be substantially more complex.

> 	* It seems like an odd choice to use a character that will show
> 	up in data a lot

True. Maybe , would be a better choice given most programming languages
use , to separate list elements anyway.

> Example:
> 
> I'm listening to commit messages from GitHub. My binding is
> github.push.*.mycoolproject, which means I want to listen to all push
> messages by anyone for a project named mycoolproject. If someone's
> github username has a period in it though, I won't see the messages
> (github.push.john.smith.mycoolproject). If I bound with
> github.push.#.mycoolproject I would see the previous message, but I
> might also get messages for other projects with GitHub users that have
> mycoolproject in their username
> (github.push.this.is.mycoolproject.user.project2). I know this isn't
> the best example, but I'm sick and my head is a bit murky ha.

Yeah, I know the feeling :/ As I said, _any_ choice is ultimately going
to collide with something else so you're always going to have to do some
sort of encoding / escaping yourself. It looks like AMQP doesn't support
any sort of escaping to prevent the . being interpreted as a semantic .
so you really are going to have to do translation to something other
than .

If, in your case, there is no character that cannot appear in a github
username (and I'd hope not - surely the whole web supports every unicode
code point by now...) then you're just not going to be able to solve
this. This possibly points to AMQP needing to change to support escaping
of . with a \

> 2. Are there are future plans to publish a message with multiple routing keys?

Not that I'm aware of.

> 	* I know I can publish the same message multiple times with different routing keys, seems inefficient

Indeed.

> For bugzilla messages, when someone changes a bug I send a
> bug.changed.[field] message. Many tools want to pivot on specific
> users though. It'd be nice to publish them also as
> bzuser at example.com.changed.bug so those tools don't have to listen to
> all changes and group by user themselves, which seems very
> inefficient.

You could put _everything_ in the routing key.
$USER.$BUG_NUMBER.$FIELD
and then the different tools just need to choose where to put # and *.
If you prefix each field value with the field name then it ensures that
such binding keys can anchor in the right place which is useful when the
range of fields overlap. Eg QA and Assign fields - if you were trying to
match changes by me to bugs, you'd be ill-advised to just do #.matthew.#
given that that would match changes _not_ by me but for bugs where I'm
the QA or assignee. Thus a key of:

user.matthew.bug.12345.qa.matthew.assignee.matthew.field.status

then allows a much more precise match of #.qa.matthew.# for example.

Matthew


More information about the rabbitmq-discuss mailing list