Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Custom RabbitMQ exchange type for sticking messages in Riak
Erlang Python

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.

RabbitMQ Riak Exchange

Latest tagged version works with RabbitMQ 2.6.1 and Riak 1.0.0 (Riak Erlang client ver 1.2.0).

This is a custom exchange type for RabbitMQ that will put any message sent to it into Riak. By default, the Riak exchange will use your exchange name as the bucket name and your routing key as the Riak key. To alter this behaviour, simply pass special message headers:

  • X-Riak-Bucket - set this to the bucket name to use.
  • X-Riak-Key - set this to the key to use.

For example, setting AMQP messages headers like the following:

  "X-Riak-Bucket": "riak-test",
  "X-Riak-Key": "mykey"

Would result in a Riak object being stored at /riak-test/mykey


To install from source:

git clone
cd riak-exchange
make deps
make package
cp deps/*.ez $RABBITMQ_HOME/plugins
cp dist/*.ez $RABBITMQ_HOME/plugins

I've also put up a tar file of the required .ez files you need to install in your RabbitMQ's plugins directory.


To use the Riak exchange type, declare your exchange as type "x-riak". In addition to forwarding messages to Riak, this also acts like a regular exchange so you can have consumers bound to this exchange and they will receive the messages as well as going to Riak.

To configure what Riak server to connect to, pass some arguments to the exchange declaration:

  • host - Hostname or IP of the Riak server to connect to.
  • port - Port number of the Riak server to connect to.
  • maxclients - The maximum number of clients to create in the pool (use more clients for higher-traffic exchanges).

NEW in version 0.1.5: The Riak exchange can act like any valid RabbitMQ exchange type. Set an argument on your exchange when you declare it named type_module and give it a valid RabbitMQ exchange type module. You can use the ones built in that come with RabbitMQ, or you can use any custom ones you or a third party have written.

Here's a sample list of possible exchange types and what you should set the type_module value to:

  • direct: rabbit_exchange_type_direct
  • fanout: rabbit_exchange_type_fanout
  • headers: rabbit_exchange_type_headers
  • topic: rabbit_exchange_type_topic
  • random: rabbit_exchange_type_random

If you don't specify anything, the exchange will default to a topic exchange.



Whatever Content-Type you set on the message will be the Content-Type used for Riak.


The Riak exchange will also translate your custom AMQP message headers into the special X-Riak-Meta- headers required by Riak. For example, if you set a custom header with the name customheader, your Riak document will have a header named X-Riak-Meta-customheader.

Something went wrong with that request. Please try again.