~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to docs/plugins/rabbitmq/rabbitmq.rst

  • Committer: Marcus Eriksson
  • Date: 2011-03-30 19:50:29 UTC
  • mto: This revision was merged to the branch mainline in revision 2263.
  • Revision ID: krummas@gmail.com-20110330195029-3l4r5kc2cr57i40l
Add RabbitMQ documentation and update the rabbitmq plugin to reconnect etc if the server goes away

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
RabbitMQ Integration
 
2
======================
 
3
 
 
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.
 
5
 
 
6
Getting started
 
7
-----------------------
 
8
First install a recent version of RabbitMQ, then install librabbitmq, this is the c library for talking to the RabbitMQ server:
 
9
 
 
10
.. code-block:: bash
 
11
 
 
12
         $ hg clone http://hg.rabbitmq.com/rabbitmq-codegen/
 
13
         $ hg clone http://hg.rabbitmq.com/rabbitmq-c/
 
14
         $ cd rabbitmq-c
 
15
         $ autoreconf -f -i
 
16
         $ ./configure
 
17
         $ make
 
18
         $ make install
 
19
 
 
20
Now you probably need to rebuild drizzle (the rabbitmq plugin is not built if librabbitmq is not installed), see :ref:`dependencies`.
 
21
 
 
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):
 
23
 
 
24
.. code-block:: bash
 
25
 
 
26
         $ sbin/drizzled7 --plugin-add rabbitmq,default-replicator --rabbitmq.use-replicator default
 
27
 
 
28
To verify that it works, you can start a generic rabbitmq listener from librabbitmq:
 
29
 
 
30
.. code-block:: bash
 
31
 
 
32
         $ ./amqp_listen localhost 5672 ReplicationExchange ReplicationRoutingKey
 
33
 
 
34
And you should see something like this when you do an INSERT/CREATE/.. (just not a select) in your newly built drizzle instance:
 
35
 
 
36
.. code-block:: bash
 
37
      
 
38
     Result 0
 
39
     Frame type 1, channel 1
 
40
     Method AMQP_BASIC_DELIVER_METHOD
 
41
     Delivery 1, exchange ReplicationExchange routingkey ReplicationRoutingKey
 
42
 
 
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.... .(.
 
49
     0000005F:
 
50
 
 
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:
 
52
 
 
53
.. code-block:: bash
 
54
 
 
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 
 
63
   
 
64
 
 
65
Implementation details
 
66
-----------------------
 
67
 
 
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
 
70