4
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
9
To load this plugin, start :program:`drizzled` with::
13
Loading the plugin may not enable or configure it. See the plugin's
14
:ref:`rabbitmq_configuration` and :ref:`rabbitmq_variables`.
16
.. seealso:: :doc:`/options` for more information about adding and removing plugins.
18
.. _rabbitmq_configuration:
23
These command line options configure the plugin when :program:`drizzled`
24
is started. See :doc:`/configuration` for more information about specifying
29
.. option:: --rabbitmq.exchange ARG
31
:Default: ReplicationExchange
32
:Variable: :ref:`rabbitmq_exchange <rabbitmq_exchange>`
34
Name of RabbitMQ exchange to publish to
36
.. option:: --rabbitmq.host ARG
39
:Variable: :ref:`rabbitmq_host <rabbitmq_host>`
41
Host name to connect to
43
.. option:: --rabbitmq.password ARG
46
:Variable: :ref:`rabbitmq_password <rabbitmq_password>`
50
.. option:: --rabbitmq.port ARG
53
:Variable: :ref:`rabbitmq_port <rabbitmq_port>`
57
.. option:: --rabbitmq.routingkey ARG
59
:Default: ReplicationRoutingKey
60
:Variable: :ref:`rabbitmq_routingkey <rabbitmq_routingkey>`
62
Name of RabbitMQ routing key to use
64
.. option:: --rabbitmq.use-replicator ARG
66
:Default: default_replicator
69
Name of the replicator plugin to use (default='default_replicator')
71
.. option:: --rabbitmq.username ARG
74
:Variable: :ref:`rabbitmq_username <rabbitmq_username>`
78
.. option:: --rabbitmq.virtualhost ARG
81
:Variable: :ref:`rabbitmq_virtualhost <rabbitmq_virtualhost>`
85
.. _rabbitmq_variables:
90
These variables show the running configuration of the plugin.
91
See `variables` for more information about querying and setting variables.
93
.. _rabbitmq_exchange:
95
* ``rabbitmq_exchange``
99
:Option: :option:`--rabbitmq.exchange`
101
Name of RabbitMQ exchange to publish to
109
:Option: :option:`--rabbitmq.host`
111
Host name to connect to
113
.. _rabbitmq_password:
115
* ``rabbitmq_password``
119
:Option: :option:`--rabbitmq.password`
129
:Option: :option:`--rabbitmq.port`
133
.. _rabbitmq_routingkey:
135
* ``rabbitmq_routingkey``
139
:Option: :option:`--rabbitmq.routingkey`
141
Name of RabbitMQ routing key to use
143
.. _rabbitmq_username:
145
* ``rabbitmq_username``
149
:Option: :option:`--rabbitmq.username`
153
.. _rabbitmq_virtualhost:
155
* ``rabbitmq_virtualhost``
159
:Option: :option:`--rabbitmq.virtualhost`
163
.. _rabbitmq_examples:
168
First install a recent version of RabbitMQ, then install librabbitmq, the C library for talking to the RabbitMQ server:
172
$ hg clone http://hg.rabbitmq.com/rabbitmq-codegen/
173
$ hg clone http://hg.rabbitmq.com/rabbitmq-c/
180
Now you probably need to rebuild Drizzle since the :program:`rabbitmq` plugin is not built if librabbitmq is not installed.
182
Finally, start :program:`drizzled` like:
186
sbin/drizzled --plugin-add rabbitmq,default-replicator \
187
--rabbitmq.use-replicator default
28
189
To verify that it works, you can start a generic rabbitmq listener from librabbitmq:
30
191
.. code-block:: bash
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
193
$ amqp_listen localhost 5672 ReplicationExchange ReplicationRoutingKey
195
And you should see something like this when you do an INSERT/CREATE/.. (just not a select) in your newly built Drizzle instance::
198
Frame type 1, channel 1
199
Method AMQP_BASIC_DELIVER_METHOD
200
Delivery 1, exchange ReplicationExchange routingkey ReplicationRoutingKey
202
00000000: 0A 17 08 01 10 87 36 18 : F0 FA D9 99 FA F1 A7 02 ......6.........
203
00000010: 20 99 81 DA 99 FA F1 A7 : 02 12 40 08 01 10 F2 FA .........@.....
204
00000020: D9 99 FA F1 A7 02 18 FC : FA D9 99 FA F1 A7 02 2A ...............*
205
00000030: 17 0A 06 0A 01 62 12 01 : 61 12 06 08 04 12 02 69 .....b..a......i
206
00000040: 64 12 05 08 01 12 01 74 : 32 11 08 01 10 01 1A 0B d......t2.......
207
00000050: 0A 01 32 0A 02 61 61 10 : 00 10 00 20 01 28 01 ..2..aa.... .(.
210
Implementation Details
211
----------------------
213
* :program:`drizzled` will not sart if the rabbitmq server is not available.
214
* 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.
216
.. _rabbitmq_authors:
223
.. _rabbitmq_version:
228
This documentation applies to **rabbitmq 0.1**.
230
To see which version of the plugin a Drizzle server is running, execute:
232
.. code-block:: mysql
234
SELECT MODULE_VERSION FROM DATA_DICTIONARY.MODULES WHERE MODULE_NAME='rabbitmq'