The routingKey (which for a Kinesis rule is used as partitionKey, and for an amqp rule as the routing key) is an interpolable string.


Interpolation is done using #{...}, similar to ruby. The contents of the interpolation is a variable name, of which the following are currently supported: channelName, message.name, and message.clientId .


This is optionally followed by a filter. Filters use a pipe syntax, similar to AngularJS filter expressions, jq, or bash. Currently supported filters are hash and moduloHash.


hash transforms the variable into a stringified 32-bit fingerprint, and takes an optional numerical argument, the base to use when stringifying (defaults to 16).


moduloHash does the same, but runs the result through a modulo function before stringifying, which is useful for bucketing. It takes one mandatory argument (the number of buckets) and one optional argument (the base).


If using a filter, you can specify a tuple of two or more variables as the input to the filter. It should be comma-separated and delimited with parentheses.


Examples:

  • "the-channel-name-is-#{channelName}"
  • "hashed channel name: #{channelName | hash} as hex, #{channelName | hash(10) as decimal}"
  • "channel name mod 256: #{channelName | moduloHash(256)}, or in octal: #{channelName | moduloHash(256, 8)}"
  • "message name: #{message.name}, clientId: #{message.clientId}"
  • "hexadecimal hash combining all message properties: #{(message.name, message.clientId, channelName) | hash}"