The demonstration code required to run these examples is available only from the standalone Apache ActiveMQ package, which you must download and install in addition to Fuse ESB.
Fuse Message Broker provides some sample code in
that enables you to
experiment with the Stomp protocol in the Ruby programming language.ActiveMQInstallDir
/example/ruby
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 yourPATH
.RubyGems package manager—RubyGems (http://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.rbAdd
to yourGemsInstallDir
/binPATH
.
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.
If you have not already done so, you also need to download and install the standalone Fuse Message Broker package from fusesource.com.
To try out the Stomp protocol, perform the following steps:
For full details of how to deploy a broker in the OSGi container, please
read Deploying a JMS Broker in Deploying into the OSGi Container. If you have not already
deployed a broker, you can create and deploy a new broker, broker1
, by entering the
following console command:
karaf@root> activemq:create-broker --name broker1
Check that the the Stomp connector is present in the broker configuration file (in
) as
follows:InstallDir
/deploy/broker1-broker.xml
<beans> ... <transportConnectors> ... <transportConnector name="stomp" uri="stomp://localhost:61613"/> </transportConnectors> ... </beans>
To connect the listener tool to the stomp://localhost:61613
endpoint
(Stomp over TCP), change directory to
ActiveMQInstallDir
/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
ActiveMQInstallDir
/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