and i’ve been workin’ like a dog
Originally uploaded by manyfires

JRuby has proved (to me at least) to be really powerful in prototyping and learning Java APIs. A few weeks ago I started thinking to rewrite one of my old Java programs in JRuby. I wrote that Java program as part of learning Java programming (so it’s not as good as I hoped) and I am no longer interested in maintaining it in Java since I’ve learned JRuby. I also thought that I made it a bit complicated to maintain. So I am hoping to simplify it by rewriting in JRuby and Ruby. It will be a challenge for me since I am still learning Ruby, but I hope I enjoy it.

The program calls various JMX APIs on a JMS server periodically and publishes outputs in XML onto JMS. The JMS server has a JMX Console, but I needed a web application for a consolidated view to monitor a number of JMS servers and clients on them.

It was not difficult at all to rewrite one part of the program, calling JMX APIs in JRuby. However, I thought twice about the data transport. Although it’s possible to use JMS in JRuby, inspired by Joe Gregorio’s RESTful JSON, I have decided to use JSON as data transport format this time. Bearing in mind the further integration with the current infrastructure at work, I have also chosen Jetty as HTTP server. Thanks to Keith who has shared his experience in running Jetty in JRuby. Jetty has JSON libraries built in, which is a bonus.

During the development, I’ve found Eyal’s JSON Viewer handy (even I have to cut & paste JSON data from cURL output) since browsers do not render response which content type is “application./json”, while you can view unformatted JSON with Firebug’s network monitoring. Does anyone know anything like Michael Bolin‘s JSON Inspector?

So far I’ve got the RESTful JSON webservice working for some GET requests. Now I need to think about URIs mapping and implementation of other JMX functions I use. I will post follow-up if I find something worthy to post.

P.S. The photo is nothing to do with this post, but as always I love to attach a wonderful photo (and story, too) I’ve found in Flickr.

Related Posts:

Advertisements