FUSE Message Broker provides some sample code in fuse-message-broker-Version/example/ruby that enables you to experiment with the Stomp protocol in the Ruby
programming language.
If you want to find out more about writing Stomp clients in other scripting languages, see the Cross Language Client Development Guide.
You must download and install the requisite packages to support the Ruby programming language before you can run the Stomp example. Install the following packages:
Ruby programming language—download and install the Ruby programming
language from http://www.ruby-lang.org/en/downloads.
Add the Ruby /bin directory to your PATH.
RubyGems package manager—RubyGems (www.rubygems.org) is a utility for installing and managing add-ons to the Ruby language. Download and install RubyGems as follows:
Download a RubyGems archive file (.tgz, .zip, or .gem) from the
RubyForge (http://rubyforge.org/frs/?group_id=126).
Unzip the RubyGems archive.
Initialize RubyGems by entering the following command:
ruby GemsInstallDir/setup.rb
Add GemsInstallDir/bin to
your PATH.
Stomp package for Ruby—install the Stomp package for Ruby by running the following command:
gem install stomp
RubyGems downloads and installs the requisite package to support the Ruby Stomp client API.
To try out the Stomp protocol, perform the following steps:
Check that the the Stomp connector is present in the default broker configuration file (in
fuse-message-broker-Version/conf/activemq.xml), as follows:
<beans>
...
<transportConnectors>
...
<transportConnector name="stomp" uri="stomp://localhost:61613"/>
</transportConnectors>
...
</beans>
Run the default broker by entering the following at a command line:
activemq
The default broker automatically takes its configuration from the default configuration file.
![]() | Note |
|---|---|
The |
To connect the listener tool to the stomp://localhost:61613 endpoint (Stomp over TCP), change directory to fuse-message-broker-Version/example/ruby and enter the following command:
ruby listener.rb
They Ruby listener connects to the endpoint, stomp://localhost:61613, by default. You could change this endpoint address by
editing the listener.rb script.
To connect the publisher tool to the stomp://localhost:61613 endpoint (Stomp over TCP), change directory to fuse-message-broker-Version/example/ruby and enter the following command:
ruby publisher.rb
You should see some output like the following:
Sent 1000 messages Sent 2000 messages Sent 3000 messages Sent 4000 messages Sent 5000 messages Sent 6000 messages Sent 7000 messages Sent 8000 messages Sent 9000 messages Sent 10000 messages Received report: Received 10000 in 4.567 seconds, remaining: 9