Monday, January 25, 2010

Replicating transactions directly to RabbitMQ

Previously RabbitReplication tailed the transaction log provided by Drizzle and then the Java application sent the protobuf serialized transaction to RabbitMQ. Now it is possible to skip the transaction log file and send the transaction directly to the RabbitMQ server without the extra step of storing it in a file first.

The code is available at and to build it with rabbitmq support you need to install librabbitmq which is a bit tricky;

Installing librabbitmq

  1. Install mercurial
  2. Branch the librabbitmq code: hg clone 
  3. Branch the rabbitmq codegen repo into a subdirectory called codegen in the rabbitmq-c directory:
    1. cd rabbitmq-c
    2. hg clone codegen
  4. Run autoconf like this: autoreconf -i 
  5. Run the configure script
  6. make
  7. make install
Build Drizzle
When librabbitmq is installed, build drizzle like this:

  1. bzr branch lp:~krummas/drizzle/rabbitmq-log
  2. config/
  3. ./configure --with-rabbitmq-log-plugin
  4. make
  5. make install
and it is done! 

Start Drizzle with RabbitMQ support
First, you can run drizzled with a --help flag to see the options available, they are all prefixed with --rabbitmq-log-XYZ. 

The default values for the parameters makes drizzle connect to localhost as "guest" and replicate to an exchange called ReplicationExchange. Start it like this to replicate changes to a rabbitmq on localhost:
$ sbin/drizzled --default-replicator-enable --rabbitmq-log-enable

The other available options are described in --help


Unknown said...

This is crazy super awesome, thanks!

オテモヤン said...
This comment has been removed by a blog administrator.
Unknown said...

Hi Marcus, thanks for the post.

Is this approach intended to replace the local Drizzle log, or be in addition to it?

If it's replacing it, I'd be concerned about the ability to do local recovery of the Drizzle instance after a crash.

If it's in addition to it, I'd be concerned about maintaining consistency between the local log and the RabbitMQ events. Specifically: what if the server crashes after writing to the local log but before the event is posted into RabbitMQ? You could have a transaction that is committed and reflected in Drizzle, but never makes it way to the downstream replication clients.

Would appreciate if you have any thoughts on this.

-- Mitch

Marcus Eriksson said...

Hi Mitch

This is meant to replace the local log, but i think it is possible to run them in parallel

Soon drizzle will support distributed (xa) transactions, this will enable transactional replication, read more here: