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.rabbitmq.com/rabbitmq-stomp/ 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, 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:
2. Next, grab the latest STOMP adapter (here we download a copy of the rabbitmq\_v1\_3\_0\_branch rather than the main trunk):
3. Compile the server itself:
4. Finally, compile the adapter, and start the server with extra options that cause the adapter to start too:
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
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.