JRuby on Rails: A Taste of Honey (for the Enterprise)

Charles Nutter, Thomas Enebo

Session Link

Status

  • Most Rails apps will now work on JRuby
  • Most pure Ruby Gems work: Redcloth, etc
  • Rails commands work
  • Ruby DB MySQL adapter works (others close)
  • Extensions that work: Mongrel, OpenSSL, YAML, RMagickJr

Advantages of JRuby

  • Supports Java Unicode strings, Ruby and Java strings go back and forth safely
  • JRuby supports Ruby's Thread. Same as a system thread so can spin off threads easily. Can pool threads.
  • Access Java libraries
  • JDBC drivers with JNDI connection pooling
  • Supports more databases than Rails, but most still don't pass all tests
  • Can be faster than Ruby (after warmup)

Disadvantages of JRuby

  • Doesn't support SQLITE3?
  • PostgreSQL still fails some tests
  • Oracle, DB2 and MSSQL still not working
  • Native extensions (C extensions) not supported, but people can port them or call to equivalent Java library
  • RMagick not supported (but they are working on it)
  • Command line likely slower (because of JVM warmup)
  • Migrations don't work on all DBs

Building, Running, Deploying

  • Install JRuby from tar
  • Add to path
  • Install with jruby -S gem install rails -y
  • Install other stuff
  • Can run with native DB, to install JDBC modify environment.rb
  • Run as normal
  • However using Mongrel means that each one needs JVM too, so it takes a lot memory

Deploy to App Server

  • Install goldspide plugin
  • jruby -S rake war:standalone:create
  • Deploy to glassfish or tomcat
  • Can run GlassFish as a gem (Alpha)