Search code examples
ruby-on-railsrubyjrubyjrubyonrails

Is it possible for me to write a JRuby script within my Rails app and use JRuby just for that script/class?


I have a Rails application that is importing data from various third parties. The jobs are taking a long time and I am looking into how I can use threads to speed this up. I know nothing about Java so apologies if this makes no sense.


Solution

  • No, JRuby is an alternate Ruby interpreter, so you cannot "switch" to it in the middle of running MRI (the standard Ruby interpreter, written in C).

    You can create threads in MRI, but many people use a background job queue to handle this type of problem. If you really wanted to, you could also write a second application in JRuby that your first application made remote calls to.