4
It is possible to replicate transactions directly to a `RabbitMQ <http://www.rabbitmq.org>`_ server from drizzle, this could be used to create advanced replication solutions, to visualize data, or to build triggers. For example, `RabbitReplication <http://www.rabbitreplication.org>`_ has been built to consume the messages from rabbitmq, transform them, and persist the data in drizzle, mysql, many nosql stores and even replicating directly to websockets for data visualization.
7
-----------------------
8
First install a recent version of RabbitMQ, then install librabbitmq, this is the c library for talking to the RabbitMQ server:
12
$ hg clone http://hg.rabbitmq.com/rabbitmq-codegen/
13
$ hg clone http://hg.rabbitmq.com/rabbitmq-c/
20
Now you probably need to rebuild drizzle (the rabbitmq plugin is not built if librabbitmq is not installed), see :ref:`dependencies`.
22
To start drizzled you need to add the replication plugins, start drizzled7 something like this (you probably want to add datadir etc as well, but these are the minimum):
26
$ sbin/drizzled7 --plugin-add rabbitmq,default-replicator --rabbitmq.use-replicator default
28
To verify that it works, you can start a generic rabbitmq listener from librabbitmq:
32
$ ./amqp_listen localhost 5672 ReplicationExchange ReplicationRoutingKey
34
And you should see something like this when you do an INSERT/CREATE/.. (just not a select) in your newly built drizzle instance:
39
Frame type 1, channel 1
40
Method AMQP_BASIC_DELIVER_METHOD
41
Delivery 1, exchange ReplicationExchange routingkey ReplicationRoutingKey
43
00000000: 0A 17 08 01 10 87 36 18 : F0 FA D9 99 FA F1 A7 02 ......6.........
44
00000010: 20 99 81 DA 99 FA F1 A7 : 02 12 40 08 01 10 F2 FA .........@.....
45
00000020: D9 99 FA F1 A7 02 18 FC : FA D9 99 FA F1 A7 02 2A ...............*
46
00000030: 17 0A 06 0A 01 62 12 01 : 61 12 06 08 04 12 02 69 .....b..a......i
47
00000040: 64 12 05 08 01 12 01 74 : 32 11 08 01 10 01 1A 0B d......t2.......
48
00000050: 0A 01 32 0A 02 61 61 10 : 00 10 00 20 01 28 01 ..2..aa.... .(.
51
It is possible to configure what `exchange <http://www.rabbitmq.com/faq.html#managing-concepts-exchanges>`_ and various other settings, these are the available config parameters:
55
--rabbitmq.host arg (=localhost) Host name to connect to
56
--rabbitmq.port arg (=5672) Port to connect to
57
--rabbitmq.virtualhost arg (=/) RabbitMQ virtualhost
58
--rabbitmq.username arg (=guest) RabbitMQ username
59
--rabbitmq.password arg (=guest) RabbitMQ password
60
--rabbitmq.use-replicator arg (=default_replicator) Name of the replicator
61
--rabbitmq.exchange arg (=ReplicationExchange) Name of RabbitMQ exchange
62
--rabbitmq.routingkey arg (=ReplicationRoutingKey) Name of RabbitMQ routing
65
Implementation details
66
-----------------------
68
* If the rabbitmq server is not available when starting drizzled, drizzled will not start
69
* If the rabbitmq server goes away, the plugin will try to reconnect and resend the message 3 times, after that, the transaction is rolled back