Integrating Ruby with Java using ActiveMQ and Stomp
Though, Ruby is a great dynamic language, and it is slowly gaining on Java
and .Net, but often folks from large corporations snub at Ruby for lack of
enterprise features. This criticism is somewhat valid as Ruby and Rails have to play
nice with existing legacy applications. Here, I am showing how Ruby and
Java can be integrated using ActiveMQ messaging middleware. ActiveMQ is a very
popular open source messaging middleware and is highly scalable, robust,
clusterable and peformant piece of software. In an ideal world, we can
use Ruby/Rails, where its strength lies, i.e., web development and
Java can be used on the serverside, where its strength lies.
Here is the recipe for integrating Java with Ruby:
Install Java SE 1.5 and Java EE 1.4
- Download Java SE 1.5 or above from http://java.sun.com/javase/downloads/index.jsp (Though, this would work with Java SE 1.4, but 1.5 has very good JMX support that helps debugging as we will see later).
- Set JAVA_HOME environment variable that points to the installation directory for Java SE.
- Download Java EE 1.4 SDK from http://java.sun.com/javaee/downloads/index.jsp.
- Set J2EE_HOME environment variable that points to the installation directory for Java EE.
Install ActiveMQ 4.0.1
- Download ActiveMQ 4.0.1 from http://www.activemq.org/site/download.html.
- Set ACTIVEMQ_HOME environment variable that points to the installation directory for ActiveMQ.
Install Ruby 1.8 and Stomp 1.0.1
- Install Ruby using One-Click from http://rubyforge.org/projects/rubyinstaller/ or use other distribution for your platform.
- Install Stomp Gem by typing “gem install stomp” or download it from http://stomp.codehaus.org/.