2c39169dc7f2b5d889403cce509f894c33141f3a
[packages/precise/mcollective.git] / website / reference / plugins / connector_rabbitmq.md
1 ---
2 layout: default
3 title: RabbitMQ Connector
4 toc: false
5 ---
6 [STOMP]: http://stomp.codehaus.org/
7 [RabbitStomp]: http://www.rabbitmq.com/stomp.html
8 [RabbitCLI]: http://www.rabbitmq.com/management-cli.html
9
10 The RabbitMQ connector uses the [STOMP] rubygem to connect to RabbitMQ servers.
11
12 This code will only work with version _1.2.2_ or newer of the Stomp gem.
13
14 ## Differences between RabbitMQ connector and Stomp Connector
15
16 The RabbitMQ connector requires MCollective 2.0.0 or newer.
17
18 While this plugin still uses the Stomp protocol to connect to RabbitMQ it does use a nubmer of
19 RabbitMQ specific optimizations to work well and as such is a Stomp connector specific to the
20 RabbitMQ broker.
21
22 ## Configuring RabbitMQ
23
24 Basic installation of the RabbitMQ broker is out of scope for this document apart from the
25 basic broker you need to enable the [Stomp plugi][RabbitStomp] and the [CLI Management Tool][RabbitCLI].
26
27 With that in place you need to create a few exchanges, topics and queues for each of your
28 sub collectives.
29
30 First we create a virtual host, user and some permissions on the vhost:
31
32 {% highlight console %}
33 rabbitmqadmin declare vhost=/mcollective
34 rabbitmqadmin declare user=mcollective password=changeme
35 rabbitmqadmin declare permission vhost=/mcollective user=mcollective configure=.* write=.* read=.*
36 {% endhighlight %}
37
38 And then we need to create two exchanges that the mcollective plugin needs:
39
40 {% highlight console %}
41 rabbitmqadmin declare exchange vhost=/mcollective name=mcollective_broadcast type=topic
42 rabbitmqadmin declare exchange vhost=/mcollective name=mcollective_directed type=direct
43 {% endhighlight %}
44
45 ## Configuring MCollective
46
47 ### Common Options
48
49 ### Failover Pools
50 A sample configuration can be seen below.
51
52 {% highlight ini %}
53 direct_addressing = 1
54
55 connector = rabbitmq
56 plugin.rabbitmq.vhost = /mcollective
57 plugin.rabbitmq.pool.size = 2
58 plugin.rabbitmq.pool.1.host = rabbit1
59 plugin.rabbitmq.pool.1.port = 6163
60 plugin.rabbitmq.pool.1.user = mcollective
61 plugin.rabbitmq.pool.1.password = changeme
62
63 plugin.rabbitmq.pool.2.host = rabbit2
64 plugin.rabbitmq.pool.2.port = 6163
65 plugin.rabbitmq.pool.2.user = mcollective
66 plugin.rabbitmq.pool.2.password = changeme
67 {% endhighlight %}
68
69 This gives it 2 servers to attempt to connect to, if the first one fails it will use the second.  Usernames and passwords can be set
70 with the environment variables STOMP_USER, STOMP_PASSWORD.
71
72 If you do not specify a port it will default to _61613_
73
74 You can also specify the following options for the Stomp gem, these are the defaults in the Stomp 1.2.2 gem:
75
76 {% highlight ini %}
77 plugin.rabbitmq.initial_reconnect_delay = 0.01
78 plugin.rabbitmq.max_reconnect_delay = 30.0
79 plugin.rabbitmq.use_exponential_back_off = true
80 plugin.rabbitmq.back_off_multiplier = 2
81 plugin.rabbitmq.max_reconnect_attempts = 0
82 plugin.rabbitmq.randomize = false
83 plugin.rabbitmq.timeout = -1
84 plugin.rabbitmq.vhost = /
85 {% endhighlight %}