Friday, February 13, 2009

JRuby Eventmachine

One of these days I need to work on ingressing JRuby, Rails, et al into my workplace. Our security policy is pretty tight, so getting things in the door is difficult. In fact, it took months just to get a JUnit add-on for testing XSLT. But that's neither here nor there. I'm here, in my few brief moments of borrowed time online, to toss a quick note out about EventMachine's Java-native IO reactor being included in the currently available gem package.

EventMachine is great in C-Ruby, letting you write highly scalable asynchronous servers. The usage is very Ruby-ish, with a tight API for specifying how to react to events like connection, receiving data, and disconnection. No massive hierarchy of Channels, Buffers, Protocol Chains, etc to figure out and import. For a while, there's been a development branch with a Java-based reactor, but it wasn't available directly from the gem. Now that's changed (probably while I was off reading a fifty page functional requirements specification at work, but I digress). Just fire up JRuby, gem install eventmachine, and have at it. The Echo server example ran just fine, other than having to kill my terminal when Control-C didn't shut it down. I think there's a standard way to trap it and get around that, though. I'm psyched that this has finally made it to JRuby.

No comments: