STOMP adapter updated for RabbitMQ 1.3.0

April 30th, 2008 tonyg

I’ve updated our STOMP adapter for RabbitMQ to fix a bug reported by Carl Bourne. In the process, I updated the code to work with the latest snapshots of RabbitMQ, including the currently-released version, v1.3.0.

You can get the code by checking it out from our repository with

hg clone http://hg.opensource.lshift.net/rabbitmq-stomp/
hg update rabbitmq_v1_3_0_branch

or you can instead download a snapshot of the current state of the adapter[1], currently at revision 392d8cc8449c.

(Update: I forgot to mention that the mercurial repository has two branches in it: default, which tracks our internal RabbitMQ server repository, and rabbitmq_v1_3_0_branch, which should stay compatible with the 1.3.0 server release. Thanks to Aman Gupta, who pointed out the problem in a comment below!)

Here’s a summary of how to build and run a STOMP-enabled RabbitMQ broker - for more details, see the original post on the topic:

  1. First, retrieve the RabbitMQ server 1.3.0 source code, and unpack it:
    curl http://www.rabbitmq.com/releases/source/rabbitmq-1.3.0.tar.gz | tar -zxvf -

  2. Next, grab the latest STOMP adapter (here we download a copy of the rabbitmq_v1_3_0_branch rather than the main trunk):
    curl http://hg.opensource.lshift.net/rabbitmq-stomp/archive/rabbitmq_v1_3_0_branch.tar.gz | tar -zxvf -

  3. Compile the server itself:
    make -C rabbitmq-1.3.0/erlang/rabbit

  4. Finally, compile the adapter, and start the server with extra options that cause the adapter to start too:
    make -C rabbitmq-stomp-rabbitmq_v1_3_0_branch run

If this is successful, you should end up with “starting STOMP-listeners …done” and “broker running” in your terminal. At this point you can try out the service - for instance, you can run Carl’s test cases if you have ruby and rubygems handy:

sudo apt-get install ruby
sudo apt-get install rubygems
sudo gem install stomp
ruby rabbitmq-stomp-rabbitmq_v1_3_0_branch/priv/tests-ruby/cb-receiver.rb

and in another window

ruby rabbitmq-stomp-rabbitmq_v1_3_0_branch/priv/tests-ruby/cb-sender.rb

It will transfer 10,000 short messages, and end up displaying

...
Test Message number 9998
Test Message number 9999
All Done!

in the receiver-side terminal.

If you’re interested in the gory details of the bug-fix itself, you can see the relevant patch here. The problem was that the code that handled abrupt socket closure wasn’t handshaking with enough of the internals of the server to ensure that the last few work items were being processed successfully. Trapping socket closure in the STOMP adapter code, and politely handshaking, turned out to be all that was required. An alternative workaround would be to use STOMP’s DISCONNECT method before closing the socket on the client side.


Footnote 1: Note that despite the misleading URL, the snapshot download really is of the STOMP adapter, and not of the broker itself! I’m making use of hgwebdir’s archive-download feature here.

Entry Filed under: Technology, RabbitMQ

5 Comments Add your own

  • 1. manuel  |  May 23rd, 2008 at 9:52 pm

    Hello,

    I’m trying to run the adapter, but it’s crashing:


    Erlang (BEAM) emulator version 5.5.5 [source] [64-bit] [async-threads:30] [kernel-poll:true]

    Eshell V5.5.5 (abort with ^G)
    (rabbit@pennylane)1> {”init terminating in doboot”,{undef,[{mnesia,systeminfo,[directory]},{rabbitmnesia,ensuremnesiadir,0},{rabbit,start,0},{init,startit,1},{init,start_em,1}]}}

    Crash dump was written to: erlcrash.dump
    init terminating in do
    boot ()
    make[1]: *** [run] Error 1

    Thank you!

  • 2. tonyg  |  May 24th, 2008 at 1:09 am

    Hi Manuel,

    Are you sure you have a full Erlang installation, including Mnesia, available? The error message you’re getting seems to indicate it cannot find the mnesia:system_info function. Some operating systems package the OTP support libraries separately from the core Erlang runtime, so perhaps there is an additional package you could install.

  • 3. tonyg  |  July 3rd, 2008 at 5:40 pm

    ((I accidentally deleted a bunch of comments I didn’t mean to delete today, so I’m having to repost them manually:))

    manuel said:

    Hey Tony,

    That was it. There was one missing pkg (’erlang’ in Ubuntu Hardy) from my erlang installation. Thanks a lot!!

  • 4. tonyg  |  July 3rd, 2008 at 5:48 pm

    ((I accidentally deleted a bunch of comments I didn’t mean to delete today, so I’m having to repost them manually:))

    Aman Gupta wrote:

    Just ran into a bug with the latest hg stomp adapter:

    {”init terminating in doboot”,{{nocatch,{error,{cannotstartapplication,rabbit,{badreturn,{{rabbit,start,[normal,[]]},{’EXIT’,{{badmatch,{ok,{0,0,0,0},’rabbitstomplistenersup0.0.0.0:61613′}},[{rabbitstomp,startlisteners,1},{rabbitstomp,start,1},{rabbitstomp,kickstart,0},{rabbit,’-start/2-fun-0-’,1},{lists,foreach,2},{rabbit,start,2},{applicationmaster,startitold,4}]}}}}}}},[{init,startit,1},{init,start_em,1}]}}

    Here’s a diff that fixes it:

    diff -r 538381ba2feb src/rabbitstomp.erl
    — a/src/rabbitstomp.erl Mon Jun 16 16:39:29 2008 +0100
    +++ b/src/rabbitstomp.erl Wed Jun 25 14:34:13 2008 -0700
    @@ -57,7 +57,7 @@
    startlisteners([]) ->
    ok;
    startlisteners([{Host, Port} | More]) ->
    - {IPAddress, Name} = rabbitnetworking:checktcplisteneraddress(rabbitstomplistenersup,
    + {ok, IPAddress, Name} = rabbitnetworking:checktcplisteneraddress(rabbitstomplistenersup,
    Host,
    Port),
    {ok,} = supervisor:start_child(

  • 5. tonyg  |  July 3rd, 2008 at 5:49 pm

    ((I accidentally deleted a bunch of comments I didn’t mean to delete today, so I’m having to repost them manually:))

    tonyg wrote:

    Aman, thank you for pointing this out. This is something I should have remarked on in the main article - I’ll update it in a second. The problem is that our internal codebase has moved on a little since RabbitMQ 1.3.0 was released, so there are actually two branches in the rabbitmq-stomp mercurial repository: default, which tracks the main branch of the server, and rabbitmqv130branch, which compiles against the released 1.3.0 release of the server.

    The diff you’ve provided catches one of the three areas where the two stomp adapter differ; there are a couple of similar changes that need to be made.

    Does it work out-of-the-box if, once you have performed your “hg clone” step, you run “hg update rabbitmqv130branch”, to switch to the maintenance branch, before compiling and running?

Leave a Comment

Required

Required, hidden

Some HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Trackback this post  |  Subscribe to the comments via RSS Feed

Calendar

April 2008
M T W T F S S
« Mar   May »
 123456
78910111213
14151617181920
21222324252627
282930  

Most Recent Posts