-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathREADME
79 lines (50 loc) · 2.18 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
RabbitMQ Queue Forwarder
============================
IMPORTANT: THIS IS A HACK.
FOR EXPERIMENTAL USE ONLY.
NOT INTENDED FOR PRODUCTION.
============================
Background:
http://somic.org/2009/12/02/hacking-rabbitmq-remote-queue-forwarders
INSTALL
=======
1. Adjust path to rabbit.hrl in rabbit_queue_forwarder.erl and compile:
% erlc rabbit_queue_forwarder.erl
2. Copy resulting rabbit_queue_forwarder.beam into rabbitmq ebin directory
(in my case, /usr/lib/erlang/lib/rabbitmq_server-1.6.0/ebin)
3. Launch 2 rabbitmq nodes with the same cookie on your machine. Below, I
will use tom@myvm (listens on port 65002) and jerry@myvm (65001)
as these 2 nodes. For example, you can create 2 directories - ./tom and
./jerry, and place the following shell script called "startup" in each:
#!/bin/sh
RABBITMQ_VAR_DIR=`pwd`
RABBITMQ_NODENAME=`basename $RABBITMQ_VAR_DIR`
RABBITMQ_NODE_IP_ADDRESS=127.0.0.1
RABBITMQ_NODE_PORT=65002 # or 65001 for jerry
RABBITMQ_PIDS_FILE=$RABBITMQ_VAR_DIR/pids
RABBITMQ_MNESIA_BASE=$RABBITMQ_VAR_DIR/mnesia
RABBITMQ_LOGS=$RABBITMQ_VAR_DIR/$RABBITMQ_NODENAME.log
RABBITMQ_SASL_LOGS=$RABBITMQ_VAR_DIR/$RABBITMQ_NODENAME-sasl.log
export RABBITMQ_NODENAME RABBITMQ_NODE_IP_ADDRESS \
RABBITMQ_NODE_PORT RABBITMQ_PIDS_FILE \
RABBITMQ_MNESIA_BASE RABBITMQ_LOGS RABBITMQ_SASL_LOGS
/usr/lib/rabbitmq/bin/rabbitmq-multi start_all 1
To start nodes, do:
% cd tom && sh startup
% cd jerry && sh startup
4. Install pika (python client lib) from http://github.com/tonyg/pika
5. Run step 1 to create queues:
% ./demo.py --step1
6. Remsh into tom and jerry:
% erl -sname one -remsh tom@myvm
% erl -sname two -remsh jerry@myvm
7. On tom, run the following:
erl> spawn(fun rabbit_queue_forwarder:qpid_lookup_server/0).
8. On jerry, run the following:
erl> rabbit_queue_forwarder:forward_queue(<<"forw_test_1">>, tom@myvm).
The output should indicate pid for forw_test_1 is now a remote pid:
{ok,{atomic,[{amqqueue,{resource,<<"/">>,queue,
<<"forw_test_1">>},
true,false,[],<10511.226.0>}]}}
9. Run step 2. It will be publishing to jerry and consuming from tom.
% ./demo.py --step2. If you see "All consumed!" in output, it worked.