SlideShare a Scribd company logo
When Ruby
                             Meets Java
                     T h e   Powe r   o f To r q u e b o x




Monday 26 March 12
About Us
               A r   u n A g r aw a l
                -    2 8 0 + c o m m i t s i n R a i l s c o re
                -    M o n g o i d c o re t e a m m e m b e r
                -    C re a t o r o f o m n i a u t h - t w i t t e r
                -    C o d i n g o n R a i l s s i n c e 2 0 0 7
                -    a g r aw a l a r u n . c o m / @ a r u n a g w


               R o   c k y J a i s w a l
                -    C o d i n g s i n c e 1 9 9 5
                -    K n o w b i t s o f J av a & R u b y
                -    E n j oy u s i n g J R u b y
                -    ro c k y j . i n / @ w h a t s u p ro c k y




Monday 26 March 12
ToDo
        - T h e E n t e r p r i s e
        - W h a t i s To r q u e b o x
        - D e m o
          - S c h e d u l i n g
          - S e r v i c e s
          - M e s s a g i n g
          - B a c k g ro u n d a b l e
          - C l u s t e r i n g & C a c h i n g
        - Pe r f o r m a n c e & S u m m a r y
        -      S u r p r i s e ! !




Monday 26 March 12
Pop Quiz

      Coolest Thing
    About JRuby(1.6) ?



Monday 26 March 12
The Enterprise




Monday 26 March 12
What If...
      Wouldn’t it be great if

            - I could use the power of Java libraries with the ease of
            Ruby

            - I could use the power of a proven Java Server without
            writing any XML

            - I could deploy my JRuby app and test it without rebuilding
            it and restarting the server




Monday 26 March 12
TORQUEBOX


                      Built upon JBoss 7
                      Built using JRuby (1.6.7)
                      Supports Rack, Rails, Sinatra
                      Everything in one box



Monday 26 March 12
TORQUEBOX




Monday 26 March 12
Installation
         - Download the distribution from torquebox.org

         OR

         - rvm jruby (1.6.7)
            jruby -J-Xmx1024m -S gem install torquebox-server --pre




Monday 26 March 12
Our Sh***y App




Monday 26 March 12
Scheduling
               Uses the battle-tested Quartz Java library

               Zero XML

               Minimal configuration

               No manual thread / process management

               No messing with cron




Monday 26 March 12
Scheduling
                     config/torquebox.yml

                     jobs:
                       mail_notifier:
                        job:      MailNotifier
                        cron:      '*/5 * * * * ?'
                        description: Deliver reminder email

                     class MailNotifier

                      def run
                       send_reminder_notification
                      end

                      def send_reminder_notification
                       puts "Sending mail ..."
                       #UserMailer.reminder_email(User.find(1)).deliver
                      end

                     end




Monday 26 March 12
Services
               Long running services with 3 line configuration

               Full access to the Rails environment

               JVM threads!




Monday 26 March 12
Services
               config/torquebox.yml
               services:
                MessageNotifier:
                  config:
                   name: hello

               class MessageNotifier
                 def initialize(opts={})
                  @name = opts['name']
                 end
                 def start
                  Thread.new { run }
                 end
                 def stop
                  @done = true
                 end
                 def run
                  until @done
                    do_something #todo
                    sleep(5)
                  end
                 end
               end
Monday 26 March 12
Messaging
          JMS supported out-of-the-box (HornetQ)


          Advanced Messaging Queuing Protocol (AMQP)
          - RabbitMQ


          Supports STOMP out of the box




Monday 26 March 12
AMQP




Monday 26 March 12
Messaging
                In a long running service -
                ...
                def do_something
                    puts "Checking the queue for messages ..."

                     bunny = Bunny.new(:logging => false)

                     # start a communication session with the amqp server
                     bunny.start

                     # declare a queue
                     q = bunny.queue(@name)

                     # get message from the queue
                     msg = q.pop[:payload]

                     puts "This is the message: " + msg.to_s

                  # close the connection
                  bunny.stop
                end


Monday 26 March 12
Backgroundable
                     As easy as A, B, C ...

                     class User < ActiveRecord::Base
                       include TorqueBox::Messaging::Backgroundable

                      always_background :send_signup_notification

                      validates_confirmation_of :
                      ...

                      def send_signup_notification(user)
                       UserMailer.welcome_email(user).deliver
                      end

                     end

Monday 26 March 12
Clustering
                 torquebox run --clustered

                 Does everything

                 Servers in a LAN are automatically clustered

                 Top it up with mod_cluster from JBoss




Monday 26 March 12
Caching
        TorqueBox provides an implementation of the Rails 3.x
        ActiveSupport::Cache::Store that exposes your
        application to the Infinispan data grid.

        Uses Infinispan by default

        Can utilize the cluster with minimal config

        Share the cache across the cluster - FTW!




Monday 26 March 12
Performance




Monday 26 March 12
Performance




Monday 26 March 12
Risks
           - Version 2 is quite stable but still at RC1

           - Upgrading JRuby will not help sometimes

           - You will be on a cutting edge open-source
           technology but documentation is great, help is
           available online and on IRC




Monday 26 March 12
Surprise!!!




Monday 26 March 12
Questions?



Monday 26 March 12
Thank You



Monday 26 March 12

More Related Content

PDF
TorqueBox - When Java meets Ruby
PDF
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
PDF
TorqueBox at DC:JBUG - November 2011
PDF
Complex Made Simple: Sleep Better with TorqueBox
PDF
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
PDF
Torquebox - O melhor dos dois mundos
KEY
Devignition 2011
PDF
TorqueBox for Rubyists
TorqueBox - When Java meets Ruby
TorqueBox: The beauty of Ruby with the power of JBoss. Presented at Devnexus...
TorqueBox at DC:JBUG - November 2011
Complex Made Simple: Sleep Better with TorqueBox
TorqueBox - Ultrapassando a fronteira entre Java e Ruby
Torquebox - O melhor dos dois mundos
Devignition 2011
TorqueBox for Rubyists

What's hot (20)

PDF
DataMapper on Infinispan
PDF
JUDCon 2010 Boston : TorqueBox
PDF
JUDCon 2010 Boston : BoxGrinder
KEY
TorqueBox - Ruby Hoedown 2011
PDF
Torquebox OSCON Java 2011
PDF
ZK_Arch_notes_20081121
PDF
Torquebox @ Raleigh.rb - April 2011
ODP
First Day With J Ruby
PDF
Spring into rails
PDF
Ruby 2.4 Internals
PDF
Java/Spring과 Node.js의공존
PPT
Find bottleneck and tuning in Java Application
PDF
JRuby @ Boulder Ruby
PPTX
201904 websocket
PDF
TorqueBox at GNUnify 2012
PDF
Fiber in the 10th year
PDF
Service-Oriented Integration With Apache ServiceMix
PDF
How DSL works on Ruby
KEY
Jruby synergy-of-ruby-and-java
PDF
Cloud Foundry, Spring and Vaadin
DataMapper on Infinispan
JUDCon 2010 Boston : TorqueBox
JUDCon 2010 Boston : BoxGrinder
TorqueBox - Ruby Hoedown 2011
Torquebox OSCON Java 2011
ZK_Arch_notes_20081121
Torquebox @ Raleigh.rb - April 2011
First Day With J Ruby
Spring into rails
Ruby 2.4 Internals
Java/Spring과 Node.js의공존
Find bottleneck and tuning in Java Application
JRuby @ Boulder Ruby
201904 websocket
TorqueBox at GNUnify 2012
Fiber in the 10th year
Service-Oriented Integration With Apache ServiceMix
How DSL works on Ruby
Jruby synergy-of-ruby-and-java
Cloud Foundry, Spring and Vaadin
Ad

Viewers also liked (20)

PDF
Flow Engines - Hack The Way You Work, Not The Time You Have
PPTX
Copy Cultures
PPT
Why go google
PDF
OPEN Silcon Valley - Clean-tech is Main-tech: How do you fit in the Green Ec...
PPTX
How we built our community using Github - Uri Cohen
PDF
Visual Conversations on Urban Futures - DRS 2016
PDF
Pattern: an open source project for migrating predictive models onto Apache H...
PDF
AWS Start-Up Tour 2009 / ShareThis
PPT
Technical Debt and Selling Rearchitecture
PPT
Traffic Signal Movie Preview
PPT
25 Words Of Social Media Wisdom Project
KEY
The Clothesline Paradox and the Sharing Economy (Keynote file)
ODP
A New Business World Within A Blockchain
PDF
Code curiosity rubyconfindia 2016 talk
PDF
Village Global 2009 : Séance 1
PPTX
Intro to Water-based Coatings
PDF
Introduction to Slideshare at Barcamp Hyderabad
PDF
Silverchair Strategies
PDF
Cascading meetup #4 @ BlueKai
KEY
Open Data: From the Information Age to the Action Age (Keynote File)
Flow Engines - Hack The Way You Work, Not The Time You Have
Copy Cultures
Why go google
OPEN Silcon Valley - Clean-tech is Main-tech: How do you fit in the Green Ec...
How we built our community using Github - Uri Cohen
Visual Conversations on Urban Futures - DRS 2016
Pattern: an open source project for migrating predictive models onto Apache H...
AWS Start-Up Tour 2009 / ShareThis
Technical Debt and Selling Rearchitecture
Traffic Signal Movie Preview
25 Words Of Social Media Wisdom Project
The Clothesline Paradox and the Sharing Economy (Keynote file)
A New Business World Within A Blockchain
Code curiosity rubyconfindia 2016 talk
Village Global 2009 : Séance 1
Intro to Water-based Coatings
Introduction to Slideshare at Barcamp Hyderabad
Silverchair Strategies
Cascading meetup #4 @ BlueKai
Open Data: From the Information Age to the Action Age (Keynote File)
Ad

Similar to When Ruby Meets Java - The Power of Torquebox (20)

PDF
Rabbitmq Boot System
PDF
Puppet: Orchestration framework?
PDF
Standing on the shoulders of giants with JRuby
PDF
Practicing Continuous Deployment
PDF
Solr Troubleshooting - TreeMap approach
PDF
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
PPTX
PDF
Range reader/writer locking for the Linux kernel
PDF
StORM preview
PDF
Slackware Demystified [SELF 2011]
PDF
The Future of JRuby - Baruco 2013
PDF
Rapid Home Provisioning
PDF
Katello on TorqueBox
PDF
Building a compiler in JRuby
PDF
Macruby - RubyConf Presentation 2010
DOCX
12c Flex ASM: Moving to Flex ASM
PDF
Use Your MySQL Knowledge to Become a MongoDB Guru
PPTX
PDF
Spark 4th Meetup Londond - Building a Product with Spark
ODP
Go Replicator
Rabbitmq Boot System
Puppet: Orchestration framework?
Standing on the shoulders of giants with JRuby
Practicing Continuous Deployment
Solr Troubleshooting - TreeMap approach
Solr Troubleshooting - Treemap Approach: Presented by Alexandre Rafolovitch, ...
Range reader/writer locking for the Linux kernel
StORM preview
Slackware Demystified [SELF 2011]
The Future of JRuby - Baruco 2013
Rapid Home Provisioning
Katello on TorqueBox
Building a compiler in JRuby
Macruby - RubyConf Presentation 2010
12c Flex ASM: Moving to Flex ASM
Use Your MySQL Knowledge to Become a MongoDB Guru
Spark 4th Meetup Londond - Building a Product with Spark
Go Replicator

Recently uploaded (20)

PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Modernizing your data center with Dell and AMD
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
KodekX | Application Modernization Development
PPTX
20250228 LYD VKU AI Blended-Learning.pptx
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
The Rise and Fall of 3GPP – Time for a Sabbatical?
Modernizing your data center with Dell and AMD
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
NewMind AI Weekly Chronicles - August'25 Week I
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
KodekX | Application Modernization Development
20250228 LYD VKU AI Blended-Learning.pptx
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
The AUB Centre for AI in Media Proposal.docx
CIFDAQ's Market Insight: SEC Turns Pro Crypto
GamePlan Trading System Review: Professional Trader's Honest Take
MYSQL Presentation for SQL database connectivity
Advanced methodologies resolving dimensionality complications for autism neur...
Dropbox Q2 2025 Financial Results & Investor Presentation

When Ruby Meets Java - The Power of Torquebox

  • 1. When Ruby Meets Java T h e Powe r o f To r q u e b o x Monday 26 March 12
  • 2. About Us A r u n A g r aw a l - 2 8 0 + c o m m i t s i n R a i l s c o re - M o n g o i d c o re t e a m m e m b e r - C re a t o r o f o m n i a u t h - t w i t t e r - C o d i n g o n R a i l s s i n c e 2 0 0 7 - a g r aw a l a r u n . c o m / @ a r u n a g w R o c k y J a i s w a l - C o d i n g s i n c e 1 9 9 5 - K n o w b i t s o f J av a & R u b y - E n j oy u s i n g J R u b y - ro c k y j . i n / @ w h a t s u p ro c k y Monday 26 March 12
  • 3. ToDo - T h e E n t e r p r i s e - W h a t i s To r q u e b o x - D e m o - S c h e d u l i n g - S e r v i c e s - M e s s a g i n g - B a c k g ro u n d a b l e - C l u s t e r i n g & C a c h i n g - Pe r f o r m a n c e & S u m m a r y - S u r p r i s e ! ! Monday 26 March 12
  • 4. Pop Quiz Coolest Thing About JRuby(1.6) ? Monday 26 March 12
  • 6. What If... Wouldn’t it be great if - I could use the power of Java libraries with the ease of Ruby - I could use the power of a proven Java Server without writing any XML - I could deploy my JRuby app and test it without rebuilding it and restarting the server Monday 26 March 12
  • 7. TORQUEBOX Built upon JBoss 7 Built using JRuby (1.6.7) Supports Rack, Rails, Sinatra Everything in one box Monday 26 March 12
  • 9. Installation - Download the distribution from torquebox.org OR - rvm jruby (1.6.7) jruby -J-Xmx1024m -S gem install torquebox-server --pre Monday 26 March 12
  • 10. Our Sh***y App Monday 26 March 12
  • 11. Scheduling Uses the battle-tested Quartz Java library Zero XML Minimal configuration No manual thread / process management No messing with cron Monday 26 March 12
  • 12. Scheduling config/torquebox.yml jobs: mail_notifier: job: MailNotifier cron: '*/5 * * * * ?' description: Deliver reminder email class MailNotifier def run send_reminder_notification end def send_reminder_notification puts "Sending mail ..." #UserMailer.reminder_email(User.find(1)).deliver end end Monday 26 March 12
  • 13. Services Long running services with 3 line configuration Full access to the Rails environment JVM threads! Monday 26 March 12
  • 14. Services config/torquebox.yml services: MessageNotifier: config: name: hello class MessageNotifier def initialize(opts={}) @name = opts['name'] end def start Thread.new { run } end def stop @done = true end def run until @done do_something #todo sleep(5) end end end Monday 26 March 12
  • 15. Messaging JMS supported out-of-the-box (HornetQ) Advanced Messaging Queuing Protocol (AMQP) - RabbitMQ Supports STOMP out of the box Monday 26 March 12
  • 17. Messaging In a long running service - ... def do_something puts "Checking the queue for messages ..." bunny = Bunny.new(:logging => false) # start a communication session with the amqp server bunny.start # declare a queue q = bunny.queue(@name) # get message from the queue msg = q.pop[:payload] puts "This is the message: " + msg.to_s # close the connection bunny.stop end Monday 26 March 12
  • 18. Backgroundable As easy as A, B, C ... class User < ActiveRecord::Base include TorqueBox::Messaging::Backgroundable always_background :send_signup_notification validates_confirmation_of : ... def send_signup_notification(user) UserMailer.welcome_email(user).deliver end end Monday 26 March 12
  • 19. Clustering torquebox run --clustered Does everything Servers in a LAN are automatically clustered Top it up with mod_cluster from JBoss Monday 26 March 12
  • 20. Caching TorqueBox provides an implementation of the Rails 3.x ActiveSupport::Cache::Store that exposes your application to the Infinispan data grid. Uses Infinispan by default Can utilize the cluster with minimal config Share the cache across the cluster - FTW! Monday 26 March 12
  • 23. Risks - Version 2 is quite stable but still at RC1 - Upgrading JRuby will not help sometimes - You will be on a cutting edge open-source technology but documentation is great, help is available online and on IRC Monday 26 March 12