README
author Tony Garnock-Jones <tonyg@lshift.net>
Fri Jun 05 15:47:00 2009 +0100 (4 weeks ago)
changeset 102 6d49eaa2fc25
parent 5841ccb4722952
permissions -rw-r--r--
merge v1_5 into default
     1 # RabbitMQ STOMP adapter
     2 
     3 ## Introduction
     4 
     5 This is a STOMP adapter plugin for use with RabbitMQ.
     6 
     7  - <http://stomp.codehaus.org/>
     8  - <http://www.rabbitmq.com/>
     9  - <https://dev.rabbitmq.com/wiki/StompGateway>
    10 
    11 You can get the code by checking it out from our repository with
    12 
    13     hg clone http://hg.rabbitmq.com/rabbitmq-stomp/
    14 
    15 Please make sure that after you have cloned the repository you update
    16 it to the correct tag for your RabbitMQ server version -- see below
    17 for details.
    18 
    19 Announcements regarding the adapter are periodically made on the
    20 RabbitMQ mailing list and on LShift's blog.
    21 
    22  - <http://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss>
    23  - <http://www.lshift.net/blog/>
    24  - <http://www.lshift.net/blog/category/lshift-sw/rabbitmq/>
    25 
    26 
    27 ## Compiling
    28 
    29 Once you have the RabbitMQ STOMP adapter code, you will need to
    30 compile it against the RabbitMQ server before configuring it.
    31 
    32 ### Compiling from released server binary packages
    33 
    34 (Please make sure that you have a version of the STOMP plugin code
    35 that is compatible with the version of the server you're using. See
    36 below for more information on this topic.)
    37 
    38 Usually, the server packages are installed to
    39 `/usr/lib/erlang/lib/rabbitmq_server-X.Y.Z`. From within the
    40 `rabbitmq-stomp` directory, issue the command
    41 
    42     make RABBIT_SERVER_INCLUDE_DIR=/usr/lib/erlang/lib/rabbitmq_server-X.Y.Z/include
    43 
    44 ### Compiling from released server source code tarballs
    45 
    46 (Please make sure that you have a version of the STOMP plugin code
    47 that is compatible with the version of the server you're using. See
    48 below for more information on this topic.)
    49 
    50 If you've downloaded a server source code tarball named
    51 `rabbitmq-server-X.Y.Z.zip`, unzip it and create a symbolic link that
    52 aliases the resulting `rabbitmq-server-X.Y.Z` directory to plain old
    53 `rabbitmq-server`:
    54 
    55     unzip rabbitmq-server-X.Y.Z.zip
    56     ln -s rabbitmq-server-X.Y.Z rabbitmq-server
    57 
    58 You will then need to compile the RabbitMQ server code:
    59 
    60     (cd rabbitmq-server; make)
    61 
    62 Finally, from within the `rabbitmq-stomp` directory, issue the command
    63 
    64     make
    65 
    66 ### Making sure the STOMP plugin version matches the server version
    67 
    68 Generally, the STOMP plugin's source code repository is tagged when a
    69 new version of the RabbitMQ server is released.
    70 
    71 For example, if you are using RabbitMQ server version 1.5.3, then
    72 examine the output of `hg tags` in your local copy of
    73 `rabbitmq-stomp`:
    74 
    75     $ hg tags
    76     tip                               93:9cd7eba4269c
    77     rabbitmq_v1_5_3                   91:5ee5e2c0b64a
    78     rabbitmq_v1_5_1                   65:2eba20816126
    79     rabbitmq_v1_5_0                   60:1a1ff5067bb6
    80     rabbitmq_v1_4_0                   49:71b922193057
    81     Migrated to mercurial             11:a28eea2c2a2b
    82 
    83 To make sure your checkout is at the `rabbitmq_v1_5_3` tag, use `hg
    84 update`:
    85 
    86     hg update rabbitmq_v1_5_3
    87 
    88 Then proceed with compiling the plugin as explained above.
    89 
    90 If there is no specific tag for the version of the server you are
    91 using, try using the newest tag that has the same major and minor
    92 version number. For instance, if you were running RabbitMQ server
    93 version 1.5.4, but no corresponding tag on `rabbitmq-stomp` was
    94 available, you should try using tag `rabbitmq_v1_5_3`. Another
    95 alternative for this hypothetical situation would be to use the tip of
    96 the 1.5.x branch:
    97 
    98     $ hg branches
    99     default                        93:9cd7eba4269c
   100     rabbitmq_v1_3_0_branch         45:90dd1726fe0b
   101     v1_5                           92:0ba97fbaea1f (inactive)
   102     $ hg update v1_5
   103     4 files updated, 0 files merged, 5 files removed, 0 files unresolved
   104     $ 
   105 
   106 ### Compiling from a Mercurial checkout
   107 
   108 If you want to use the bleeding-edge features of the broker and/or the
   109 STOMP adapter, you will need to clone and compile three separate
   110 repositories that work together:
   111 
   112     hg clone http://hg.rabbitmq.com/rabbitmq-server
   113     hg clone http://hg.rabbitmq.com/rabbitmq-codegen
   114     hg clone http://hg.rabbitmq.com/rabbitmq-stomp
   115     (cd rabbitmq-server; make)
   116     (cd rabbitmq-stomp; make)
   117 
   118 ### Compiling from anywhere else
   119 
   120 If you have a file system layout not covered above, you can
   121 investigate setting the Makefile variables `RABBIT_SOURCE_ROOT`,
   122 `RABBIT_SERVER_SOURCE_ROOT`, and/or `RABBIT_SERVER_INCLUDE_DIR`. For
   123 example, if you had a particular version of `rabbit.hrl` and
   124 `rabbit_framing.hrl` you wanted to use, you might say
   125 
   126     make RABBIT_SERVER_INCLUDE_DIR=/path/to/include
   127 
   128 so that the STOMP adapter source code can find the `rabbit.hrl` and
   129 `rabbit_framing.hrl` files in the `/path/to/include` directory.
   130 
   131 
   132 ## Running the STOMP adapter
   133 
   134 ### Configuring the server to start the plugin automatically
   135 
   136 Most RabbitMQ server packages are set up to cause the server to pick
   137 up configuration from `/etc/rabbitmq/rabbitmq.conf`. To tell the
   138 server to start your plugin, first make sure it is compiled, and then
   139 add the following text to `/etc/rabbitmq/rabbitmq.conf`:
   140 
   141     SERVER_START_ARGS='
   142       -pa /path/to/rabbitmq-stomp/ebin 
   143       -rabbit
   144          stomp_listeners [{"0.0.0.0",61613}]
   145          extra_startup_steps [{"STOMP-listeners",rabbit_stomp,kickstart,[]}]'
   146 
   147 making sure to update the `/path/to/rabbitmq-stomp/ebin` appropriately
   148 for your system. Then restart the server with
   149 
   150     sudo /etc/init.d/rabbitmq-server restart
   151 
   152 ### Checking that the adapter is running
   153 
   154 If the adapter is running, you should be able to connect to port 61613
   155 using a STOMP client of your choice. In a pinch, `telnet` or netcat
   156 (`nc`) will do nicely:
   157 
   158     $ nc localhost 61613
   159     dummy
   160     dummy
   161     ERROR
   162     message:Invalid frame
   163     content-type:text/plain
   164     content-length:22
   165     
   166     Could not parse frame
   167     $ 
   168 
   169 That `ERROR` message indicates that the adapter is listening and
   170 attempting to parse STOMP frames.
   171 
   172 Another option is to try out the examples that come with the STOMP
   173 adapter -- see below.
   174 
   175 ### Running the adapter during development
   176 
   177 If you are working with the full source code for the RabbitMQ server,
   178 and you either have the `../rabbitmq-server` directory or
   179 `RABBIT_SERVER_SOURCE_ROOT` Makefile variable set up correctly, you
   180 can simply say `make run`:
   181 
   182     make run
   183 
   184 or
   185 
   186     make RABBIT_SERVER_SOURCE_ROOT=/some/other/path/to/rabbitmq-server run
   187 
   188 If this is successful, you should end up with `starting
   189 STOMP-listeners ...done` and `broker running` in your terminal.
   190 
   191 
   192 ## Running the examples
   193 
   194 ### Ruby
   195 
   196 At this point you can try out the service - for instance, you can run
   197 the Ruby examples if you have Ruby and rubygems handy:
   198 
   199     sudo apt-get install ruby
   200     sudo apt-get install rubygems
   201     sudo gem install stomp
   202     ruby examples/ruby/cb-receiver.rb
   203 
   204 and in another window
   205 
   206     ruby examples/ruby/cb-sender.rb
   207 
   208 It will transfer 10,000 short messages, and end up displaying
   209 
   210     ...
   211     Test Message number 9998
   212     Test Message number 9999
   213     All Done!
   214 
   215 in the receiver-side terminal.
   216 
   217 
   218 ### Perl
   219 
   220     $ sudo cpan -i Net::Stomp
   221 
   222 The examples are those from the `Net::Stomp` documentation - run
   223 `perldoc Net::Stomp` to read the originals.
   224 
   225 Run the receiver before the sender to make sure the queue exists at
   226 the moment the send takes place. In one terminal window, start the
   227 receiver:
   228 
   229     $ perl examples/perl/rabbitmq_stomp_recv.pl
   230 
   231 In another terminal window, run the sender:
   232 
   233     $ perl examples/perl/rabbitmq_stomp_send.pl
   234     $ perl examples/perl/rabbitmq_stomp_send.pl "hello world"
   235     $ perl examples/perl/rabbitmq_stomp_send.pl QUIT
   236 
   237 The receiver's window should contain the received messages:
   238 
   239     $ perl examples/perl/rabbitmq_stomp_recv.pl 
   240     test message
   241     hello
   242     QUIT
   243     $