STOMP adapter updated for RabbitMQ 1.3.0

(This page is a mirrored copy of an article originally posted on the LShift blog; see the archive index here.)

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
hg update rabbitmq_v1_3_0_branch

UPDATE: use the default branch these days, unless you’re still running 1.3.0!

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

(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 | 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 | 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.


On 23 May, 2008 at 9:52 pm, manuel wrote:


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!

On 24 May, 2008 at 1:09 am, tonyg wrote:

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.

On 3 July, 2008 at 5:40 pm, tonyg wrote:

((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!!

On 3 July, 2008 at 5:48 pm, tonyg wrote:

((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([]) ->
startlisteners([{Host, Port} | More]) ->
- {IPAddress, Name} = rabbitnetworking:checktcplisteneraddress(rabbitstomplistenersup,
+ {ok, IPAddress, Name} = rabbitnetworking:checktcplisteneraddress(rabbitstomplistenersup,
{ok,} = supervisor:start_child(

On 3 July, 2008 at 5:49 pm, tonyg wrote:

((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?

On 26 August, 2008 at 1:57 am, jake mallory wrote:

What are the known limitations for the stomp gateway?

On 28 August, 2008 at 12:22 pm, tonyg wrote:

@jake: It implements all the protocol described at, hopefully faithfully. There are quite a few AMQP features that are not yet exposed via the STOMP gateway, though; for those, you’ll need to either use a real AMQP client, or send us a patch! (Patches welcome :-) )

On 29 August, 2008 at 5:49 pm, jake mallory wrote:

thanks. I found ruby-ampq ( and qpid ( which I might try instead.

On 23 November, 2008 at 10:11 pm, Hans wrote:

Hi Tony,

I can not find your uploaded file, nor can your mercurial system. Could you upload it again, please? Thanks

On 24 November, 2008 at 12:07 pm, tonyg wrote:

Hi Hans,

Sorry about that — we’ve moved the STOMP adapter to our RabbitMQ hg repository:

A snapshot can be downloaded from

On 8 January, 2009 at 10:22 pm, sidda wrote:

Hi Tony,

I ran the rabbitmq-stomp adapter to verify the Stomp client that we have implemented at Kaazing. It works well - thank you.

In the process of running rabbitmq-stomp adapter with RabbitMQ, I noticed that content-length and content-type headers are added stomp frames where required. But, for the ERROR frame the error message is in text and the content-length header set, but the content-type header is not set.

My code, being a generic STOMP client, cannot assume that the content of the ERROR frame is always going to be text - as content-length header is typically used by STOMP servers to send binary data. So, I am writing this comment to find out if you can add content-type header to the ERROR frame in rabbitmq-stomp adapter. I can provide you with the patch required (it is a one line change).

Best Regards,

On 29 January, 2009 at 3:10 pm, tonyg wrote:

Sidda, that’s a good suggestion. Thanks! I’ve just committed a patch that sets a content-type of text/plain on error messages. The changeset is here:

On 24 March, 2009 at 5:17 pm, Sig wrote:

I’m receiving the following with a custom erl built in /usr/local

make -C rabbitmq-stomp-rabbitmq_v1_3_0_branch run
make: Entering directory '/usr/local/src/rabbitmq-stomp-rabbitmq_v1_3_0_branch'
make -C ../rabbitmq-1.3.0/erlang/rabbit run \
        RABBIT_ARGS='-pa '"$(pwd)/ebin"' -rabbit \
            stomp_listeners [{\"\",61613}] \
            extra_startup_steps [{\"STOMP-listeners\",rabbit_stomp,kickstart,[]}]’
make[1]: Entering directory ‘/usr/local/src/rabbitmq-1.3.0/erlang/rabbit’
NODE_IP_ADDRESS= NODE_PORT= NODE_ONLY=true LOG_BASE=/tmp  RABBIT_ARGS=”-pa /usr/local/src/rabbitmq-stomp-rabbitmq_v1_3_0_branch/ebin -rabbit
        stomp_listeners [{\"\",61613}]
        extra_startup_steps [{\"STOMP-listeners\",rabbit_stomp,kickstart,[]}] -s rabbit” MNESIA_DIR=/tmp/rabbitmq-rabbit-mnesia ./scripts/rabbitmq-server
{error_logger,{{2009,3,24},{10,20,27}},”Protocol: ~p: register error: ~p~n”,["inet_tcp",{{badmatch,{error,duplicate_name}},[{inet_tcp_dist,listen,1},{net_kernel,start_protos,4},{net_kernel,start_protos,3},{net_kernel,init_node,2},{net_kernel,init,1},{gen_server,init_it,6},{proc_lib,init_p,5}]}]}
{”Kernel pid terminated”,application_controller,”{application_start_failure,kernel,{shutdown,{kernel,start,[normal,[]]}}}”}

On 25 March, 2009 at 10:00 am, tonyg wrote:

@Sig: could the problem be that you already have another RabbitMQ instance started? Using “make run” causes a whole broker instance with embedded STOMP adapter to start.

Also, these days, you should probably use the default branch if you can, not the 1.3 support branch; the latest release of RabbitMQ is 1.5.3, and there’s a corresponding STOMP adapter tag. Try this, after ensuring that RabbitMQ is not running:

hg clone
hg clone
hg clone
(cd rabbitmq-server; hg up rabbitmq_v1_5_3)
(cd rabbitmq-codegen; hg up rabbitmq_v1_5_3)
(cd rabbitmq-stomp; hg up rabbitmq_v1_5_3)
make -C rabbitmq-server
make -C rabbitmq-stomp run

On 25 March, 2009 at 10:12 am, tonyg wrote:

For those who haven’t yet seen it: the RabbitMQ mailing list is a great place to get help using RabbitMQ, including configuring the STOMP adapter etc. You can subscribe etc via

On 26 March, 2009 at 2:50 am, Sig wrote:

Thank You!

I finally realized that I had a version running in the background. . I still might join the mailing list, this is a very impressive project.