JMS with JRuby and ActiveMQ  Hot PDF Print E-mail
Tag it:
Delicious
Furl it!
Digg
NewsVine
Reddit
YahooMyWeb
Technorati
Articles Reviews Ruby
Written by George Malamidis   
Tuesday, 10 July 2007
{mos_sb_discuss:50}

One of the most interesting (and powerful) features of JRuby is the ability to access and manipulate Java classes and libraries. The code below creates, configures and starts an instance of an ActiveMQ Broker that accepts connections based on the Stomp protocol.



require "java"
     require "apache-activemq-4.1.1.jar"

       include_class "org.apache.activemq.broker.BrokerService"

     broker = BrokerService.new
  broker.add_connector("stomp://localhost:61613")
 broker.start

Supposing this code has been saved in a file named broker.rb, and given a working JRuby installation, we can start the Broker by invoking jruby broker.rb.

The apache-activemq-4.1.1.jar archive must be in the same location as the broker.rb script, in order for it to be successfully loaded.

Alternatively it can be placed in any of the locations described in the Require and Load behavior page on the JRuby Wiki.

Ruby supports Stomp via the Stomp library which can be installed as a gem (gem install stomp). Using Stomp we can create Listeners that can subscribe to Topics on our queue.

Read more

 

 

 

User reviews

There are no user reviews for this item.

Add new review




Powered by jReviews

Last Updated ( Tuesday, 10 July 2007 )
 
< Prev   Next >