SlideShare ist ein Scribd-Unternehmen logo
1 von 108
Downloaden Sie, um offline zu lesen
Toby Crawley
                                              UCLUG
       Creative  Commons  BY-­SA  3.0
                                           March 2011

Thursday, March 10, 2011
whoami

                    • C  >  Java  >  PHP  >  Java  >  Ruby  >  
                      Java?
                    • emacs,  though  I’ve  heard  of  vi
                    • Red  Hat  Senior  Engineer  
                    • proud  member  of

Thursday, March 10, 2011
Agenda
                           • High-­level  structure  and  TorqueBox  
                             setup
                           • Web,  Messaging,  Scheduling,  
                             Services,  Clustering




Thursday, March 10, 2011
TorqueBox
                 the power of JBoss with the expressiveness of Ruby




Thursday, March 10, 2011
TorqueBox:  what?

                    • A  “real”  app  server  for  Ruby
                    • Founded  in  2008
                    • Bob  McWhirter’s  “labor  of  love”
                    • 100%  open-­source,  LGPL  license
                    • Reflects  a  strong  commitment  to  
                      Ruby  from  Red  Hat


Thursday, March 10, 2011
TorqueBox:  why?

                    • “Native”  support  for  Rack  apps
                    • Built-­in  background  processing
                    • Built-­in  scheduling
                    • Built-­in  clustering
                    • Easily  scalable
                    • Optionally  enterprisey
Thursday, March 10, 2011
JRuby
                           a good idea done well




Thursday, March 10, 2011
JRuby:  why?

                    • Very  fast  runtime
                    • Real  threads
                    • Java  libraries
                    • Java  tools
                    • Healthy  community

Thursday, March 10, 2011
JRuby:  why  not?

                    • Slower  start  up
                    • Native  gems
                     • FFI
                     • C  extension  support
                    • Some  Ruby  libs  not  thread-­safe

Thursday, March 10, 2011
JBoss  AS
                           the enterprisey good parts




Thursday, March 10, 2011
I  promise...

                    • No  XML  
                    • No  Java  *
                    • No  war  files  *
                    • Only  Ruby  and  YAML
                     * Unless you really want to

Thursday, March 10, 2011
JBoss  AS6

                    • Tomcat  for  web
                    • Infinispan  for  caching
                    • HornetQ  for  messaging
                    • Quartz  for  scheduling
                    • PicketBox  for  authentication
                    • mod_cluster  for  clustering
Thursday, March 10, 2011
AS  =  Application  Server

                    • Not  just  “web  server  +  interpreter”
                    • More  like  initd  than  httpd
                    • Can  host  multiple,  disparate  apps  
                      simultaneously
                    • Provides  basic  services  to  all  the  
                      apps  it  hosts


Thursday, March 10, 2011
Hot  Deployment
                $JBOSS_HOME/server/default/deploy/

            •      anything  added  to  deploy/  
                   will  get  deployed
            •      anything  removed  from  
                   deploy/  will  get  
                   undeployed
            •      anything  updated  in  
                   deploy/  will  get  redeployed
            •      TorqueBox  deployers  
                   make  JBoss  grok  YAML  
                   and  ruby  archives



Thursday, March 10, 2011
Hot  Deployment
                $JBOSS_HOME/server/default/deploy/

            •      anything  added  to  deploy/  
                   will  get  deployed
                         deployment  
            •      anything  removed  from  
                          descriptors
                   deploy/  will  get  
                   undeployed
            •      anything  updated  in  
                   deploy/  will  get  redeployed
            •      TorqueBox  deployers  
                   make  JBoss  grok  YAML  
                   and  ruby  archives



Thursday, March 10, 2011
Hot  Deployment
                $JBOSS_HOME/server/default/deploy/

            •      anything  added  to  deploy/  
                   will  get  deployed
                         deployment  
            •      anything  removed  from  
                          descriptors
                   deploy/  will  get  
                   undeployed
            •      anything  updated  in  
                   deploy/  will  get  redeployed
            •      TorqueBox  deployers  
                   make  JBoss  grok  YAML  
                   and  ruby  archives



Thursday, March 10, 2011
Hot  Deployment
                $JBOSS_HOME/server/default/deploy/

            •      anything  added  to  deploy/  
                   will  get  deployed
            •      anything  removed  from  
                   deploy/  will  get  
                   undeployed
                          zip  files  
            •      anything  updated  in  
                        (archives)
                   deploy/  will  get  redeployed
            •      TorqueBox  deployers  
                   make  JBoss  grok  YAML  
                   and  ruby  archives



Thursday, March 10, 2011
Hot  Deployment
                $JBOSS_HOME/server/default/deploy/

            •      anything  added  to  deploy/  
                   will  get  deployed
            •      anything  removed  from  
                   deploy/  will  get  
                   undeployed
                          zip  files  
            •      anything  updated  in  
                        (archives)
                   deploy/  will  get  redeployed
            •      TorqueBox  deployers  
                   make  JBoss  grok  YAML  
                   and  ruby  archives



Thursday, March 10, 2011
Setting  Up  TorqueBox
                           in 3 easy steps!




Thursday, March 10, 2011
easy  install

         $  wget  http://torquebox.org/torquebox-­dev.zip
         $  unzip  torquebox-­dev.zip

         $  export  TORQUEBOX_HOME=$PWD/torquebox-­1*
         $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss
         $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby

         $  export  PATH=$JRUBY_HOME/bin:$PATH



Thursday, March 10, 2011
easy  install

         $  wget  http://torquebox.org/torquebox-­dev.zip
         $  unzip  torquebox-­dev.zip

         $  export  TORQUEBOX_HOME=$PWD/torquebox-­1*
         $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss
         $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby

         $  export  PATH=$JRUBY_HOME/bin:$PATH



Thursday, March 10, 2011
easy  install

         $  wget  http://torquebox.org/torquebox-­dev.zip
         $  unzip  torquebox-­dev.zip

         $  export  TORQUEBOX_HOME=$PWD/torquebox-­1*
         $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss
         $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby

         $  export  PATH=$JRUBY_HOME/bin:$PATH



Thursday, March 10, 2011
easy  install

         $  wget  http://torquebox.org/torquebox-­dev.zip
         $  unzip  torquebox-­dev.zip Make  sure  the  jruby  
                                     found  in  your  path  is  in  
                                      $JRUBY_HOME/bin.
         $  export  TORQUEBOX_HOME=$PWD/torquebox-­1*
         $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss
         $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby

         $  export  PATH=$JRUBY_HOME/bin:$PATH



Thursday, March 10, 2011
easy  install

         $  wget  http://torquebox.org/torquebox-­dev.zip
         $  unzip  torquebox-­dev.zip Make  sure  the  jruby  
                                     found  in  your  path  is  in  
                                      $JRUBY_HOME/bin.
         $  export  TORQUEBOX_HOME=$PWD/torquebox-­1*
         $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss
         $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby

         $  export  PATH=$JRUBY_HOME/bin:$PATH



Thursday, March 10, 2011
easy  install


         $  jruby  -­S  gem  install  bundler
         $  jruby  -­S  gem  install  rails
         $  jruby  -­S  gem  install  sinatra



Thursday, March 10, 2011
rake  tasks
                Rakefile




              require  "torquebox-­rake-­support"




Thursday, March 10, 2011
rake  tasks

         rake  torquebox:run
                 Run  TorqueBox  server

         rake  torquebox:deploy[context_path]
                 Deploy  the  app  in  the  current  directory

         rake  torquebox:undeploy
                 Undeploy  the  app  in  the  current  directory



Thursday, March 10, 2011
rake  tasks

                       Start  torquebox:run  in  its  own  
                       shell  and  leave  it  running.  Instead  
                       of  script/server  or  shotgun  
                       or  thin  or  whatever  else,  
                       use  torquebox:deploy.



Thursday, March 10, 2011
deployment  descriptors


                       torquebox:deploy  creates  
                       a  deployment  descriptor  in  the  
                       JBoss  deploy/  directory



Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development
              web:
                context: myapp
                host:    www.yourhost.com
                static: public
                rackup: config.ru
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development
              web:                      The  fully-­qualified  
                context: myapp
                host:    www.yourhost.com
                                          path  to  the  app.    
                static: public         This  will  be  the  value  
              environment:                    of  either  
                                         RAILS_ROOT  or  
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com RACK_ROOT

Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development
              web:                      The  fully-­qualified  
                context: myapp
                host:    www.yourhost.com
                                          path  to  the  app.    
                static: public         This  will  be  the  value  
              environment:                    of  either  
                                         RAILS_ROOT  or  
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com RACK_ROOT

Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development
              web:
                context: myapp         The  runtime  mode  of  
                host:    www.yourhost.com
                static: public
                                        the  app.    This  will  be  
              environment:               either  RAILS_ENV  
                                           or  RACK_ENV
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development
              web:
                context: myapp         The  runtime  mode  of  
                host:    www.yourhost.com
                static: public
                                        the  app.    This  will  be  
              environment:               either  RAILS_ENV  
                                           or  RACK_ENV
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                                    The  app’s  context  path  
               deploy/myapp-­knob.yml “sub  URI”):
                                         (or  
                               http://localhost:8080/myapp
              application:            Can  be  set  via  rake:
                root:         rake  torquebox:deploy[myapp]
                         /path/to/myapp
                env:     development The  default  is  root:
              web:               http://localhost:8080/
                context: myapp
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                                    The  app’s  context  path  
               deploy/myapp-­knob.yml “sub  URI”):
                                         (or  
                               http://localhost:8080/myapp
              application:            Can  be  set  via  rake:
                root:         rake  torquebox:deploy[myapp]
                         /path/to/myapp
                env:     development The  default  is  root:
              web:               http://localhost:8080/
                context: myapp
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                                           A  list  of  virtual  
                root:    /path/to/myapp
                env:     development
                                        hostnames  to  which  
              web:                        to  bind  the  app.
                context: myapp
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                                           A  list  of  virtual  
                root:    /path/to/myapp
                env:     development
                                        hostnames  to  which  
              web:                        to  bind  the  app.
                context: myapp
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development      The  location  of  the  
              web:                             app’s  static  
                context: myapp              content,  either  
                host:    www.yourhost.com
                                          absolute  or  relative  
                static: public
              environment:                 to  the  app’s  root.
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp
                env:     development      The  location  of  the  
              web:                             app’s  static  
                context: myapp              content,  either  
                host:    www.yourhost.com
                                          absolute  or  relative  
                static: public
              environment:                 to  the  app’s  root.
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp Any  environment  
                env:     development
              web:                     variables  required  
                context: myapp            by  the  app.
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors
                deploy/myapp-­knob.yml

              application:
                root:    /path/to/myapp Any  environment  
                env:     development
              web:                     variables  required  
                context: myapp            by  the  app.
                host:    www.yourhost.com
                static: public
              environment:
                MAIL_HOST: mail.yourhost.com
                REPLY_TO: you@yourhost.com


Thursday, March 10, 2011
deployment  descriptors

                    •      config/torquebox.yml  
                    •      internal  descriptors  have  the  
                           same  structure  as  the  
                           external  ones  in  deploy/
                    •      may  be  used  to  provide  your  
                           own  reasonable  defaults


Thursday, March 10, 2011
Web
                           make rack, not war




Thursday, March 10, 2011
jruby-­rack

                    • All  rack-­based  frameworks  
                      supported:  rails,  sinatra,  etc
                    • No  packaging  required:  apps  deploy  
                      from  where  they  sit  on  disk
                    • No  redeploy  necessary  to  see  
                      changes  when  using  rack  reloading  
                           or  rails  development  mode


Thursday, March 10, 2011
database  connectivity
                Gemfile



              gem  "activerecord-­jdbc-­adapter"

              gem  "jdbc-­postgres"
              #  gem  "jdbc-­sqlite3"
              #  gem  "jdbc-­mysql"



Thursday, March 10, 2011
rails  template

                    • Adds  TorqueBox  rake  tasks
                    • Adds  the  JDBC  sqlite3  gems
                    • Adds  TorqueBox  session_store
                    • Adds  Backgroundable  module

Thursday, March 10, 2011
my  first  rails  app
         $  jruby  -­S  gem  install  bundler  rails

         $  jruby  -­S  rails  new  myapp  -­m  
                 $TORQUEBOX_HOME/share/rails/template.rb

         $  cd  myapp
         $  jruby  -­S  bundle  install

         $  jruby  -­S  rake  torquebox:deploy


Thursday, March 10, 2011
Messaging
                            asynchronicity




Thursday, March 10, 2011
lots  of  options




Thursday, March 10, 2011
lots  of  options
    RabbitMQ                 cron
                           Resque       BackgroundDRb
                                workling      CronEdit
                BackgroundJob
      Kestral                 rufus-scheduler JobFu
                      Ap4r
    Amazon SQS                   async_observer
                   Taskr Sparrow            Background-Fu
     beanstalkd     DelayedJob    RailsCron
                                               Open4
                                Conveyor
      WorkerQueue daemons                 rake
                                               ActiveMQ
       starling     Spawn ActiveMessaging

Thursday, March 10, 2011
TorqueBox::Messaging


                    • JMS  (Java  Message  Service)  
                      is  an  API  for  messaging
                    • implementation
                      HornetQ  is  the  JBoss  JMS  




Thursday, March 10, 2011
TorqueBox::Messaging
                    • No  extra  tables  in  your  database
                    • No  external  system  to  manage
                    • Little  to  no  config  required  at  all
                    • System  gets  redeployed  w/app
                    • Efficient  loading  of  rails  environment
                    • Automatic  load  balancing  and  retries
                    • Works  on  Windows,  if  you  care
Thursday, March 10, 2011
Tasks
                app/tasks/email_task.rb

              class  EmailTask  <  TorqueBox::Messaging::Task
                  def  welcome(payload)
                      person  =  Person.find_by_id(payload[:id])
                      if  person
                          #  send  the  email
                          person.welcomed  =  true
                          person.save!
                      end
                  end
              end




Thursday, March 10, 2011
Tasks
                app/tasks/email_task.rb

              class  EmailTask  <  TorqueBox::Messaging::Task
                  def  welcome(payload)
                      person  =  Person.find_by_id(payload[:id])
                      if  person
                          #  send  the  email
                          person.welcomed  =  true
                          person.save!
                      end
                  end
              end




Thursday, March 10, 2011
Tasks
                app/tasks/email_task.rb

              class  EmailTask  <  TorqueBox::Messaging::Task
                  def  welcome(payload)
                      person  =  Person.find_by_id(payload[:id])
                      if  person
                          #  send  the  email
                          person.welcomed  =  true
                          person.save!
                      end
                  end
              end




Thursday, March 10, 2011
Tasks
                app/tasks/email_task.rb

              class  EmailTask  <  TorqueBox::Messaging::Task
                  def  welcome(payload)
                      person  =  Person.find_by_id(payload[:id])
                      if  person
                          #  send  the  email
                          person.welcomed  =  true
                          person.save!
                      end
                  end
              end




Thursday, March 10, 2011
Tasks
                app/controllers/people_controller.rb


              class  PeopleController  <  ApplicationController
                  def  create
                      @person  =  Person.new(params[:person])
                      respond_to  do  |format|
                          if  @person.save
                              EmailTask.async(:welcome,  :id  =>  person.id)
                              #  respond  appropriately
                          end
                      end
                  end
              end




Thursday, March 10, 2011
Tasks
                app/controllers/people_controller.rb


              class  PeopleController  <  ApplicationController
                  def  create
                      @person  =  Person.new(params[:person])
                      respond_to  do  |format|
                          if  @person.save
                              EmailTask.async(:welcome,  :id  =>  person.id)
                              #  respond  appropriately
                          end
                      end
                  end
              end




Thursday, March 10, 2011
Tasks

                       Call  them  from  your  
                       controllers,  models,  and  
                       observers,  or  even  other  
                       tasks.  Even  in  non-­Rails  
                       apps!


Thursday, March 10, 2011
Backgroundable

                       Inspired  by  DelayedJob’s  
                       handle_asynchronously,  
                       it’s  trivial  to  create  implicit  
                       background  Tasks.


Thursday, March 10, 2011
Backgroundable
                lib/something.rb

              include  TorqueBox::Messaging  

              class  Something
                  include  Backgroundable
                  always_background  :foo
                  def  foo;;  end
                  def  bar;;  end
              end
              ...
              @something.foo
              @something.background.bar


Thursday, March 10, 2011
Backgroundable
                lib/something.rb

              include  TorqueBox::Messaging  

              class  Something
                  include  Backgroundable
                  always_background  :foo
                  def  foo;;  end
                  def  bar;;  end
              end
              ...
              @something.foo
              @something.background.bar


Thursday, March 10, 2011
Backgroundable
                lib/something.rb

              include  TorqueBox::Messaging  

              class  Something
                  include  Backgroundable
                  always_background  :foo
                  def  foo;;  end
                  def  bar;;  end
              end
              ...
              @something.foo
              @something.background.bar


Thursday, March 10, 2011
Backgroundable
                lib/something.rb

              include  TorqueBox::Messaging  

              class  Something
                  include  Backgroundable
                  always_background  :foo
                  def  foo;;  end
                  def  bar;;  end
              end
              ...
              @something.foo
              @something.background.bar


Thursday, March 10, 2011
Backgroundable
                app/models/slow_poke.rb


              class  SlowPoke  <  ActiveRecord::Base
                  always_background  :takes_forever
                  def  takes_forever;;  end
                  def  might_take_awhile;;  end
              end

              @slowpoke.takes_forever
              @slowpoke.background.might_take_awhile



Thursday, March 10, 2011
Queues
                       Tasks  are  built  on  top  of  
                       Queues.    Of  course,  you  may  
                       build  your  own  messaging  
                       based  apps  by  defining  your  
                       own  Queues,  Topics,  and  their  
                       message  Processors  yourself.


Thursday, March 10, 2011
Queues
                config/torquebox.yml

              queues:
                  /queues/questions:

                  /queues/answers:
                      durable:  false


Thursday, March 10, 2011
Processors

                       You  can  create  a  processor  
                       class  to  receive  messages  
                       from  a  Topic  or  Queue



Thursday, March 10, 2011
Processors
                config/torquebox.yml

              messaging:
                /topics/print:
                  - PrintHandler
                  - PopularHandler
                    concurrency: 5
                /queues/students:
                  PrintHandler:
                    config:
                      color: true


Thursday, March 10, 2011
Processors
                config/torquebox.yml

              messaging:
                /topics/print:
                  - PrintHandler
                  - PopularHandler
                    concurrency: 5
                /queues/students:
                  PrintHandler:
                    config:
                      color: true


Thursday, March 10, 2011
Processors
                config/torquebox.yml

              messaging:
                /topics/print:
                  - PrintHandler
                  - PopularHandler
                    concurrency: 5
                /queues/students:
                  PrintHandler:
                    config:
                      color: true


Thursday, March 10, 2011
Processors
                config/torquebox.yml

              messaging:
                /topics/print:
                  - PrintHandler
                  - PopularHandler
                    concurrency: 5
                /queues/students:
                  PrintHandler:
                    config:
                      color: true


Thursday, March 10, 2011
Processors
                app/models/print_handler.rb

              include  TorqueBox::Messaging

              class  PrintHandler  <  MessageProcessor
                  def  on_message(body)
                      puts  "Processing  #{body}  of  #{message}"
                  end
                  def  configure(opts)
                      @color  =  opts['color']
                  end
              end



Thursday, March 10, 2011
Queues  (again)


                       But  how  do  you  send  a  
                       message?



Thursday, March 10, 2011
Queues
                example

              include  TorqueBox::Messaging
              questions  =  Queue.new  '/queues/questions'
              answers  =  Queue.new  '/queues/answers'
                
              Thread.new  do
                  questions.publish  "What  time  is  it?"
                  puts  answers.receive(  :timeout  =>  1000  )
              end
                
              puts  questions.receive
              answers.publish  Time.now


Thursday, March 10, 2011
Queues
                example

              include  TorqueBox::Messaging
              questions  =  Queue.new  '/queues/questions'
              answers  =  Queue.new  '/queues/answers'
                
              Thread.new  do
                  questions.publish  "What  time  is  it?"
                  puts  answers.receive(  :timeout  =>  1000  )
              end
                
              puts  questions.receive
              answers.publish  Time.now


Thursday, March 10, 2011
Queues
                example

              include  TorqueBox::Messaging
              questions  =  Queue.new  '/queues/questions'
              answers  =  Queue.new  '/queues/answers'
                
              Thread.new  do
                  questions.publish  "What  time  is  it?"
                  puts  answers.receive(  :timeout  =>  1000  )
              end
                
              puts  questions.receive
              answers.publish  Time.now


Thursday, March 10, 2011
Queues
                example

              include  TorqueBox::Messaging
              questions  =  Queue.new  '/queues/questions'
              answers  =  Queue.new  '/queues/answers'
                
              Thread.new  do
                  questions.publish  "What  time  is  it?"
                  puts  answers.receive(  :timeout  =>  1000  )
              end
                
              puts  questions.receive
              answers.publish  Time.now


Thursday, March 10, 2011
Topics
                    • behavior  is  different,  but  interface  is  
                      the  same.
                    • all  subscribers  of  a  topic  see  each  
                      message,  but  only  one  subscriber  
                           will  see  any  message  from  a  queue  
                    •      use  topics:  section  of  
                           torquebox.yml  to  define  topics
                    •      use  TorqueBox::Messaging::Topic

Thursday, March 10, 2011
Scheduling
                           get regular later




Thursday, March 10, 2011
Jobs
                app/jobs/newsletter_sender.rb

              class  NewsletterSender
                
                  def  run()
                      subscriptions  =  Subscription.find(:all)
                      subscriptions.each  do  |e|
                          send_newsletter(  e  )
                      end
                  end
                
              end



Thursday, March 10, 2011
Jobs
                config/torquebox.yml

              jobs:
                  monthly_newsletter:
                      description:  first  of  month
                      job:  NewsletterSender
                      cron:  ‘0  0  0  1  *  ?’
                  
                  process_tps_reports:
                      job:  TPSReportProcessor
                      cron:  ‘0  0  0  0  MON  ?’

Thursday, March 10, 2011
Jobs
                    “Fire  every  half  hour  from  10am  until  1pm  
                        on  the  third  Friday  of  each  month”

                       0   */30 10-13      ?       *     FRI#3

                Seconds Minutes   Hours   DOM    Month   DOW     Year

                                                          1-7
                                                  1-12           1970-
                                          1-31           SUN-
                    0-59   0-59    0-23           JAN-           2099
                                          ?LW            SAT
                                                  DEC            empty
                                                         ?L#


Thursday, March 10, 2011
Jobs
                    • More  portable.  What  is  the  first  day  
                      of  the  week  on  BSD  again?    What’s  
                           cron  on  Windows?
                    •      Self  contained  within  the  app.    No  
                           external  systems  to  manage  and  
                           keep  in  sync.
                    •      Full  rails  environment  loaded  and  
                           available.


Thursday, March 10, 2011
Services
                           run along, lil’ daemon




Thursday, March 10, 2011
Services

                       Long-­running,  non-­web  
                       “daemons”  that  share  the  
                       runtime  environment  and  
                       deployment  lifecycle  of  
                       your  app.


Thursday, March 10, 2011
Services
                    • Represented  as  a  class  with  
                      optional  initialize(Hash),  
                           start()  and  stop()  methods,  
                           which  should  each  return  quickly.
                    •      Typically  will  start  a  long-­running  
                           loop  in  a  thread  and  respond  to  
                           external  events.
                    •      Configured  via  services:  section  in  
                           torquebox.yml

Thursday, March 10, 2011
Services
                config/torquebox.yml

              services:
                  IrcBot:
                      server:  freenode.net
                      channel:  #torquebox
                      publish:  /topics/irc

                  MyMudServer:

                  SomeOtherService:


Thursday, March 10, 2011
Services
                app/services/my_service.rb

              class  MyService
                  def  initialize(opts={})
                      name  =  opts[:publish]
                      @queue  =  Queue.new(name)
                  end
                  def  start  
                      Thread.new  {  run  }  
                  end
                  def  stop  
                      @done  =  true
                  end
              end


Thursday, March 10, 2011
Services
                app/services/my_service.rb

              class  MyService
                  def  initialize(opts={})
                      name  =  opts[:publish]
                      @queue  =  Queue.new(name)
                  end
                  def  start  
                      Thread.new  {  run  }  
                  end
                  def  stop  
                      @done  =  true
                  end
              end


Thursday, March 10, 2011
Services
                app/services/my_service.rb

              class  MyService
                  def  initialize(opts={})
                      name  =  opts[:publish]
                      @queue  =  Queue.new(name)
                  end
                  def  start  
                      Thread.new  {  run  }  
                  end
                  def  stop  
                      @done  =  true
                  end
              end


Thursday, March 10, 2011
Services
                app/services/my_service.rb

              class  MyService
                  def  initialize(opts={})
                      name  =  opts[:publish]
                      @queue  =  Queue.new(name)
                  end
                  def  start  
                      Thread.new  {  run  }  
                  end
                  def  stop  
                      @done  =  true
                  end
              end


Thursday, March 10, 2011
Services
                app/services/my_service.rb


              class  MyService
                  def  run
                      until  @done
                          @queue.publish(Time.now)
                          sleep(1)  
                      end
                  end
              end



Thursday, March 10, 2011
Services
                app/services/my_service.rb


              class  MyService
                  def  run
                      until  @done
                          @queue.publish(Time.now)
                          sleep(1)  
                      end
                  end
              end



Thursday, March 10, 2011
Clustering
                           less failure faster




Thursday, March 10, 2011
out-­of-­the-­box
                    • JBoss  provides
                     • session  replication
                     • load-­balanced  messaging
                    • mod_cluster  provides
                     • session  affinity
                     • intelligent  load-­balanced  web
                     • failover
Thursday, March 10, 2011
mod_cluster
                       A  reverse  proxy  implemented  
                       as  an  Apache  module  with  
                       JBoss  awareness.  Constantly  
                       gathers  load  statistics  and  
                       deployment  availability  for  
                       intelligent  request  distribution.


Thursday, March 10, 2011
mod_cluster




Thursday, March 10, 2011
mod_cluster

                    • Dynamic  configuration
                    • Server-­side  load  factor  calculation
                    • Fine-­grained  web  app  lifecycle
                    • AJP  (Apache  JServ  Protocol)  is  
                      optional.  HTTP[S]  is  also  supported.



Thursday, March 10, 2011
Caching
                           hot off of the press!




Thursday, March 10, 2011
Caching
                    • Infinispan  cache  store
                    • non-­clustered:
                     • local
                    • clustered:
                     • invalidation
                     • replicated
                     • distributed
Thursday, March 10, 2011
Caching
                config/application.rb


              config.cache_store  =  
              :torque_box_store,  :mode  =>  :local

              #  or

              config.cache_store  =  
              ActiveSupport::Cache::TorqueBoxStore.new
              (  :mode  =>  :local  )



Thursday, March 10, 2011
Other  Cool  Stuff
                            well, we think it’s cool




Thursday, March 10, 2011
Cool  Stuff

                    • StompBox  -­  git  based  deploys
                    • BackStage  -­  see  behind  the  curtain
                    • Built  in  authentication
                    • Benchmarking/speed  improvements

Thursday, March 10, 2011
Live  Demo
                            wish me luck




Thursday, March 10, 2011
Resources
                    • http://torquebox.org
                    • #torquebox  on  freenode
                    • https://github.com/torquebox
                    • http://twitter.com/torquebox
                    • http://projectodd.org
                    • https://github.com/tobias/
                      torquebox_rails_sample

Thursday, March 10, 2011
Thanks!
                           questions?




Thursday, March 10, 2011

Weitere ähnliche Inhalte

Was ist angesagt?

Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with FabricJonas Nockert
 
Crank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxCrank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxJim Crossley
 
Apache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on TomcatApache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on TomcatTomitribe
 
Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant Jim Crossley
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the LazyMaurício Linhares
 
Jeff mc cune sf 2010
Jeff mc cune sf 2010Jeff mc cune sf 2010
Jeff mc cune sf 2010Puppet
 
Declare independence from your it department sysadmin skills for symfony dev...
Declare independence from your it department  sysadmin skills for symfony dev...Declare independence from your it department  sysadmin skills for symfony dev...
Declare independence from your it department sysadmin skills for symfony dev...Pablo Godel
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternPuppet
 
Puppet Camp London 2015: Puppet Contained
Puppet Camp London 2015: Puppet ContainedPuppet Camp London 2015: Puppet Contained
Puppet Camp London 2015: Puppet ContainedPuppet
 
Puppetconf2011 small
Puppetconf2011 smallPuppetconf2011 small
Puppetconf2011 smallPuppet
 
Create a Professional Blog with WordPress: Chapter 2 Installing Wordpress
Create a Professional Blog with WordPress: Chapter 2 Installing WordpressCreate a Professional Blog with WordPress: Chapter 2 Installing Wordpress
Create a Professional Blog with WordPress: Chapter 2 Installing WordpressAtit Patumvan
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby ConferenceJohn Woodell
 
RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011Marcello Barnaba
 
High quality iOS development
High quality iOS developmentHigh quality iOS development
High quality iOS developmentRobin Lu
 

Was ist angesagt? (20)

Django Deployment with Fabric
Django Deployment with FabricDjango Deployment with Fabric
Django Deployment with Fabric
 
Vagrant at LA Ruby
Vagrant at LA RubyVagrant at LA Ruby
Vagrant at LA Ruby
 
Crank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBoxCrank Up Your Apps With TorqueBox
Crank Up Your Apps With TorqueBox
 
Apache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on TomcatApache TomEE, Java EE 6 Web Profile {and more} on Tomcat
Apache TomEE, Java EE 6 Web Profile {and more} on Tomcat
 
Exceptable
ExceptableExceptable
Exceptable
 
Introducing Immutant
Introducing Immutant Introducing Immutant
Introducing Immutant
 
Plone on Amazon EC2
Plone on Amazon EC2Plone on Amazon EC2
Plone on Amazon EC2
 
The Fast, The Slow and the Lazy
The Fast, The Slow and the LazyThe Fast, The Slow and the Lazy
The Fast, The Slow and the Lazy
 
Jeff mc cune sf 2010
Jeff mc cune sf 2010Jeff mc cune sf 2010
Jeff mc cune sf 2010
 
Declare independence from your it department sysadmin skills for symfony dev...
Declare independence from your it department  sysadmin skills for symfony dev...Declare independence from your it department  sysadmin skills for symfony dev...
Declare independence from your it department sysadmin skills for symfony dev...
 
Immutant
ImmutantImmutant
Immutant
 
Designing Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles PatternDesigning Puppet: Roles/Profiles Pattern
Designing Puppet: Roles/Profiles Pattern
 
Puppet Camp London 2015: Puppet Contained
Puppet Camp London 2015: Puppet ContainedPuppet Camp London 2015: Puppet Contained
Puppet Camp London 2015: Puppet Contained
 
Puppetconf2011 small
Puppetconf2011 smallPuppetconf2011 small
Puppetconf2011 small
 
Create a Professional Blog with WordPress: Chapter 2 Installing Wordpress
Create a Professional Blog with WordPress: Chapter 2 Installing WordpressCreate a Professional Blog with WordPress: Chapter 2 Installing Wordpress
Create a Professional Blog with WordPress: Chapter 2 Installing Wordpress
 
Red Dirt Ruby Conference
Red Dirt Ruby ConferenceRed Dirt Ruby Conference
Red Dirt Ruby Conference
 
RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011RVM and Ruby Interpreters @ RSC Roma 03/2011
RVM and Ruby Interpreters @ RSC Roma 03/2011
 
Devignition 2011
Devignition 2011Devignition 2011
Devignition 2011
 
App Engine Meetup
App Engine MeetupApp Engine Meetup
App Engine Meetup
 
High quality iOS development
High quality iOS developmentHigh quality iOS development
High quality iOS development
 

Ähnlich wie UCLUG TorqueBox - 03/08/2011

Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edgeericholscher
 
2011 JavaOne Fun with EJB 3.1 and OpenEJB
2011 JavaOne Fun with EJB 3.1 and OpenEJB2011 JavaOne Fun with EJB 3.1 and OpenEJB
2011 JavaOne Fun with EJB 3.1 and OpenEJBDavid Blevins
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignDATAVERSITY
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Leonardo Borges
 
Drupal Theming Limitations
Drupal Theming LimitationsDrupal Theming Limitations
Drupal Theming LimitationsGeorge Terezakis
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSCaridy Patino
 
How Plone's Security Works
How Plone's Security WorksHow Plone's Security Works
How Plone's Security WorksMatthew Wilkes
 
DevOps Introduction @Cegeka
DevOps Introduction @CegekaDevOps Introduction @Cegeka
DevOps Introduction @Cegekadieterdm
 
Apache TomEE, Java EE 6 Web Profile on Tomcat - David Blevins
Apache TomEE, Java EE 6 Web Profile on Tomcat - David BlevinsApache TomEE, Java EE 6 Web Profile on Tomcat - David Blevins
Apache TomEE, Java EE 6 Web Profile on Tomcat - David Blevinsjaxconf
 
Apache Tomcat + Java EE = Apache TomEE
Apache Tomcat + Java EE = Apache TomEEApache Tomcat + Java EE = Apache TomEE
Apache Tomcat + Java EE = Apache TomEEJacek Laskowski
 
Seattle OpenStack Meetup
Seattle OpenStack MeetupSeattle OpenStack Meetup
Seattle OpenStack MeetupMatt Ray
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHPConFoo
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slidescarllerche
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & HowGraham Tackley
 

Ähnlich wie UCLUG TorqueBox - 03/08/2011 (20)

Java to scala
Java to scalaJava to scala
Java to scala
 
Deploying on the cutting edge
Deploying on the cutting edgeDeploying on the cutting edge
Deploying on the cutting edge
 
Railsconf 2010
Railsconf 2010Railsconf 2010
Railsconf 2010
 
2011 JavaOne Fun with EJB 3.1 and OpenEJB
2011 JavaOne Fun with EJB 3.1 and OpenEJB2011 JavaOne Fun with EJB 3.1 and OpenEJB
2011 JavaOne Fun with EJB 3.1 and OpenEJB
 
MongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema DesignMongoDB at Sailthru: Scaling and Schema Design
MongoDB at Sailthru: Scaling and Schema Design
 
Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011) Clouds against the Floods (RubyConfBR2011)
Clouds against the Floods (RubyConfBR2011)
 
Drupal Theming Limitations
Drupal Theming LimitationsDrupal Theming Limitations
Drupal Theming Limitations
 
Caridy patino - node-js
Caridy patino - node-jsCaridy patino - node-js
Caridy patino - node-js
 
Conquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JSConquistando el Servidor con Node.JS
Conquistando el Servidor con Node.JS
 
RunDeck
RunDeckRunDeck
RunDeck
 
How Plone's Security Works
How Plone's Security WorksHow Plone's Security Works
How Plone's Security Works
 
DevOps Introduction @Cegeka
DevOps Introduction @CegekaDevOps Introduction @Cegeka
DevOps Introduction @Cegeka
 
Apache TomEE, Java EE 6 Web Profile on Tomcat - David Blevins
Apache TomEE, Java EE 6 Web Profile on Tomcat - David BlevinsApache TomEE, Java EE 6 Web Profile on Tomcat - David Blevins
Apache TomEE, Java EE 6 Web Profile on Tomcat - David Blevins
 
Apache Tomcat + Java EE = Apache TomEE
Apache Tomcat + Java EE = Apache TomEEApache Tomcat + Java EE = Apache TomEE
Apache Tomcat + Java EE = Apache TomEE
 
Seattle OpenStack Meetup
Seattle OpenStack MeetupSeattle OpenStack Meetup
Seattle OpenStack Meetup
 
The Solar Framework for PHP
The Solar Framework for PHPThe Solar Framework for PHP
The Solar Framework for PHP
 
Homebrew atlrug
Homebrew atlrugHomebrew atlrug
Homebrew atlrug
 
Frozen Rails Slides
Frozen Rails SlidesFrozen Rails Slides
Frozen Rails Slides
 
CommonJS Frameworks
CommonJS FrameworksCommonJS Frameworks
CommonJS Frameworks
 
Java to Scala: Why & How
Java to Scala: Why & HowJava to Scala: Why & How
Java to Scala: Why & How
 

Kürzlich hochgeladen

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Kürzlich hochgeladen (20)

Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

UCLUG TorqueBox - 03/08/2011

  • 1. Toby Crawley UCLUG Creative  Commons  BY-­SA  3.0 March 2011 Thursday, March 10, 2011
  • 2. whoami • C  >  Java  >  PHP  >  Java  >  Ruby  >   Java? • emacs,  though  I’ve  heard  of  vi • Red  Hat  Senior  Engineer   • proud  member  of Thursday, March 10, 2011
  • 3. Agenda • High-­level  structure  and  TorqueBox   setup • Web,  Messaging,  Scheduling,   Services,  Clustering Thursday, March 10, 2011
  • 4. TorqueBox the power of JBoss with the expressiveness of Ruby Thursday, March 10, 2011
  • 5. TorqueBox:  what? • A  “real”  app  server  for  Ruby • Founded  in  2008 • Bob  McWhirter’s  “labor  of  love” • 100%  open-­source,  LGPL  license • Reflects  a  strong  commitment  to   Ruby  from  Red  Hat Thursday, March 10, 2011
  • 6. TorqueBox:  why? • “Native”  support  for  Rack  apps • Built-­in  background  processing • Built-­in  scheduling • Built-­in  clustering • Easily  scalable • Optionally  enterprisey Thursday, March 10, 2011
  • 7. JRuby a good idea done well Thursday, March 10, 2011
  • 8. JRuby:  why? • Very  fast  runtime • Real  threads • Java  libraries • Java  tools • Healthy  community Thursday, March 10, 2011
  • 9. JRuby:  why  not? • Slower  start  up • Native  gems • FFI • C  extension  support • Some  Ruby  libs  not  thread-­safe Thursday, March 10, 2011
  • 10. JBoss  AS the enterprisey good parts Thursday, March 10, 2011
  • 11. I  promise... • No  XML   • No  Java  * • No  war  files  * • Only  Ruby  and  YAML * Unless you really want to Thursday, March 10, 2011
  • 12. JBoss  AS6 • Tomcat  for  web • Infinispan  for  caching • HornetQ  for  messaging • Quartz  for  scheduling • PicketBox  for  authentication • mod_cluster  for  clustering Thursday, March 10, 2011
  • 13. AS  =  Application  Server • Not  just  “web  server  +  interpreter” • More  like  initd  than  httpd • Can  host  multiple,  disparate  apps   simultaneously • Provides  basic  services  to  all  the   apps  it  hosts Thursday, March 10, 2011
  • 14. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archives Thursday, March 10, 2011
  • 15. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed deployment   • anything  removed  from   descriptors deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archives Thursday, March 10, 2011
  • 16. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed deployment   • anything  removed  from   descriptors deploy/  will  get   undeployed • anything  updated  in   deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archives Thursday, March 10, 2011
  • 17. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed zip  files   • anything  updated  in   (archives) deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archives Thursday, March 10, 2011
  • 18. Hot  Deployment $JBOSS_HOME/server/default/deploy/ • anything  added  to  deploy/   will  get  deployed • anything  removed  from   deploy/  will  get   undeployed zip  files   • anything  updated  in   (archives) deploy/  will  get  redeployed • TorqueBox  deployers   make  JBoss  grok  YAML   and  ruby  archives Thursday, March 10, 2011
  • 19. Setting  Up  TorqueBox in 3 easy steps! Thursday, March 10, 2011
  • 20. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATH Thursday, March 10, 2011
  • 21. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATH Thursday, March 10, 2011
  • 22. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATH Thursday, March 10, 2011
  • 23. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip Make  sure  the  jruby   found  in  your  path  is  in   $JRUBY_HOME/bin. $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATH Thursday, March 10, 2011
  • 24. easy  install $  wget  http://torquebox.org/torquebox-­dev.zip $  unzip  torquebox-­dev.zip Make  sure  the  jruby   found  in  your  path  is  in   $JRUBY_HOME/bin. $  export  TORQUEBOX_HOME=$PWD/torquebox-­1* $  export  JBOSS_HOME=$TORQUEBOX_HOME/jboss $  export  JRUBY_HOME=$TORQUEBOX_HOME/jruby $  export  PATH=$JRUBY_HOME/bin:$PATH Thursday, March 10, 2011
  • 25. easy  install $  jruby  -­S  gem  install  bundler $  jruby  -­S  gem  install  rails $  jruby  -­S  gem  install  sinatra Thursday, March 10, 2011
  • 26. rake  tasks Rakefile require  "torquebox-­rake-­support" Thursday, March 10, 2011
  • 27. rake  tasks rake  torquebox:run        Run  TorqueBox  server rake  torquebox:deploy[context_path]        Deploy  the  app  in  the  current  directory rake  torquebox:undeploy        Undeploy  the  app  in  the  current  directory Thursday, March 10, 2011
  • 28. rake  tasks Start  torquebox:run  in  its  own   shell  and  leave  it  running.  Instead   of  script/server  or  shotgun   or  thin  or  whatever  else,   use  torquebox:deploy. Thursday, March 10, 2011
  • 29. deployment  descriptors torquebox:deploy  creates   a  deployment  descriptor  in  the   JBoss  deploy/  directory Thursday, March 10, 2011
  • 30. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp host: www.yourhost.com static: public rackup: config.ru environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 31. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: The  fully-­qualified   context: myapp host: www.yourhost.com path  to  the  app.     static: public This  will  be  the  value   environment: of  either   RAILS_ROOT  or   MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com RACK_ROOT Thursday, March 10, 2011
  • 32. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: The  fully-­qualified   context: myapp host: www.yourhost.com path  to  the  app.     static: public This  will  be  the  value   environment: of  either   RAILS_ROOT  or   MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com RACK_ROOT Thursday, March 10, 2011
  • 33. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp The  runtime  mode  of   host: www.yourhost.com static: public the  app.    This  will  be   environment: either  RAILS_ENV   or  RACK_ENV MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 34. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development web: context: myapp The  runtime  mode  of   host: www.yourhost.com static: public the  app.    This  will  be   environment: either  RAILS_ENV   or  RACK_ENV MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 35. deployment  descriptors The  app’s  context  path   deploy/myapp-­knob.yml “sub  URI”): (or   http://localhost:8080/myapp application: Can  be  set  via  rake: root: rake  torquebox:deploy[myapp] /path/to/myapp env: development The  default  is  root: web: http://localhost:8080/ context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 36. deployment  descriptors The  app’s  context  path   deploy/myapp-­knob.yml “sub  URI”): (or   http://localhost:8080/myapp application: Can  be  set  via  rake: root: rake  torquebox:deploy[myapp] /path/to/myapp env: development The  default  is  root: web: http://localhost:8080/ context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 37. deployment  descriptors deploy/myapp-­knob.yml application: A  list  of  virtual   root: /path/to/myapp env: development hostnames  to  which   web: to  bind  the  app. context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 38. deployment  descriptors deploy/myapp-­knob.yml application: A  list  of  virtual   root: /path/to/myapp env: development hostnames  to  which   web: to  bind  the  app. context: myapp host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 39. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development The  location  of  the   web: app’s  static   context: myapp content,  either   host: www.yourhost.com absolute  or  relative   static: public environment: to  the  app’s  root. MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 40. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp env: development The  location  of  the   web: app’s  static   context: myapp content,  either   host: www.yourhost.com absolute  or  relative   static: public environment: to  the  app’s  root. MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 41. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp Any  environment   env: development web: variables  required   context: myapp by  the  app. host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 42. deployment  descriptors deploy/myapp-­knob.yml application: root: /path/to/myapp Any  environment   env: development web: variables  required   context: myapp by  the  app. host: www.yourhost.com static: public environment: MAIL_HOST: mail.yourhost.com REPLY_TO: you@yourhost.com Thursday, March 10, 2011
  • 43. deployment  descriptors • config/torquebox.yml   • internal  descriptors  have  the   same  structure  as  the   external  ones  in  deploy/ • may  be  used  to  provide  your   own  reasonable  defaults Thursday, March 10, 2011
  • 44. Web make rack, not war Thursday, March 10, 2011
  • 45. jruby-­rack • All  rack-­based  frameworks   supported:  rails,  sinatra,  etc • No  packaging  required:  apps  deploy   from  where  they  sit  on  disk • No  redeploy  necessary  to  see   changes  when  using  rack  reloading   or  rails  development  mode Thursday, March 10, 2011
  • 46. database  connectivity Gemfile gem  "activerecord-­jdbc-­adapter" gem  "jdbc-­postgres" #  gem  "jdbc-­sqlite3" #  gem  "jdbc-­mysql" Thursday, March 10, 2011
  • 47. rails  template • Adds  TorqueBox  rake  tasks • Adds  the  JDBC  sqlite3  gems • Adds  TorqueBox  session_store • Adds  Backgroundable  module Thursday, March 10, 2011
  • 48. my  first  rails  app $  jruby  -­S  gem  install  bundler  rails $  jruby  -­S  rails  new  myapp  -­m          $TORQUEBOX_HOME/share/rails/template.rb $  cd  myapp $  jruby  -­S  bundle  install $  jruby  -­S  rake  torquebox:deploy Thursday, March 10, 2011
  • 49. Messaging asynchronicity Thursday, March 10, 2011
  • 51. lots  of  options RabbitMQ cron Resque BackgroundDRb workling CronEdit BackgroundJob Kestral rufus-scheduler JobFu Ap4r Amazon SQS async_observer Taskr Sparrow Background-Fu beanstalkd DelayedJob RailsCron Open4 Conveyor WorkerQueue daemons rake ActiveMQ starling Spawn ActiveMessaging Thursday, March 10, 2011
  • 52. TorqueBox::Messaging • JMS  (Java  Message  Service)   is  an  API  for  messaging • implementation HornetQ  is  the  JBoss  JMS   Thursday, March 10, 2011
  • 53. TorqueBox::Messaging • No  extra  tables  in  your  database • No  external  system  to  manage • Little  to  no  config  required  at  all • System  gets  redeployed  w/app • Efficient  loading  of  rails  environment • Automatic  load  balancing  and  retries • Works  on  Windows,  if  you  care Thursday, March 10, 2011
  • 54. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end end Thursday, March 10, 2011
  • 55. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end end Thursday, March 10, 2011
  • 56. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end end Thursday, March 10, 2011
  • 57. Tasks app/tasks/email_task.rb class  EmailTask  <  TorqueBox::Messaging::Task    def  welcome(payload)        person  =  Person.find_by_id(payload[:id])        if  person            #  send  the  email            person.welcomed  =  true            person.save!        end    end end Thursday, March 10, 2011
  • 58. Tasks app/controllers/people_controller.rb class  PeopleController  <  ApplicationController    def  create        @person  =  Person.new(params[:person])        respond_to  do  |format|            if  @person.save                EmailTask.async(:welcome,  :id  =>  person.id)                #  respond  appropriately            end        end    end end Thursday, March 10, 2011
  • 59. Tasks app/controllers/people_controller.rb class  PeopleController  <  ApplicationController    def  create        @person  =  Person.new(params[:person])        respond_to  do  |format|            if  @person.save                EmailTask.async(:welcome,  :id  =>  person.id)                #  respond  appropriately            end        end    end end Thursday, March 10, 2011
  • 60. Tasks Call  them  from  your   controllers,  models,  and   observers,  or  even  other   tasks.  Even  in  non-­Rails   apps! Thursday, March 10, 2011
  • 61. Backgroundable Inspired  by  DelayedJob’s   handle_asynchronously,   it’s  trivial  to  create  implicit   background  Tasks. Thursday, March 10, 2011
  • 62. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.bar Thursday, March 10, 2011
  • 63. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.bar Thursday, March 10, 2011
  • 64. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.bar Thursday, March 10, 2011
  • 65. Backgroundable lib/something.rb include  TorqueBox::Messaging   class  Something    include  Backgroundable    always_background  :foo    def  foo;;  end    def  bar;;  end end ... @something.foo @something.background.bar Thursday, March 10, 2011
  • 66. Backgroundable app/models/slow_poke.rb class  SlowPoke  <  ActiveRecord::Base    always_background  :takes_forever    def  takes_forever;;  end    def  might_take_awhile;;  end end @slowpoke.takes_forever @slowpoke.background.might_take_awhile Thursday, March 10, 2011
  • 67. Queues Tasks  are  built  on  top  of   Queues.    Of  course,  you  may   build  your  own  messaging   based  apps  by  defining  your   own  Queues,  Topics,  and  their   message  Processors  yourself. Thursday, March 10, 2011
  • 68. Queues config/torquebox.yml queues:    /queues/questions:    /queues/answers:        durable:  false Thursday, March 10, 2011
  • 69. Processors You  can  create  a  processor   class  to  receive  messages   from  a  Topic  or  Queue Thursday, March 10, 2011
  • 70. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: true Thursday, March 10, 2011
  • 71. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: true Thursday, March 10, 2011
  • 72. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: true Thursday, March 10, 2011
  • 73. Processors config/torquebox.yml messaging: /topics/print: - PrintHandler - PopularHandler concurrency: 5 /queues/students: PrintHandler: config: color: true Thursday, March 10, 2011
  • 74. Processors app/models/print_handler.rb include  TorqueBox::Messaging class  PrintHandler  <  MessageProcessor    def  on_message(body)        puts  "Processing  #{body}  of  #{message}"    end    def  configure(opts)        @color  =  opts['color']    end end Thursday, March 10, 2011
  • 75. Queues  (again) But  how  do  you  send  a   message? Thursday, March 10, 2011
  • 76. Queues example include  TorqueBox::Messaging questions  =  Queue.new  '/queues/questions' answers  =  Queue.new  '/queues/answers'   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.now Thursday, March 10, 2011
  • 77. Queues example include  TorqueBox::Messaging questions  =  Queue.new  '/queues/questions' answers  =  Queue.new  '/queues/answers'   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.now Thursday, March 10, 2011
  • 78. Queues example include  TorqueBox::Messaging questions  =  Queue.new  '/queues/questions' answers  =  Queue.new  '/queues/answers'   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.now Thursday, March 10, 2011
  • 79. Queues example include  TorqueBox::Messaging questions  =  Queue.new  '/queues/questions' answers  =  Queue.new  '/queues/answers'   Thread.new  do    questions.publish  "What  time  is  it?"    puts  answers.receive(  :timeout  =>  1000  ) end   puts  questions.receive answers.publish  Time.now Thursday, March 10, 2011
  • 80. Topics • behavior  is  different,  but  interface  is   the  same. • all  subscribers  of  a  topic  see  each   message,  but  only  one  subscriber   will  see  any  message  from  a  queue   • use  topics:  section  of   torquebox.yml  to  define  topics • use  TorqueBox::Messaging::Topic Thursday, March 10, 2011
  • 81. Scheduling get regular later Thursday, March 10, 2011
  • 82. Jobs app/jobs/newsletter_sender.rb class  NewsletterSender      def  run()        subscriptions  =  Subscription.find(:all)        subscriptions.each  do  |e|            send_newsletter(  e  )        end    end   end Thursday, March 10, 2011
  • 83. Jobs config/torquebox.yml jobs:    monthly_newsletter:        description:  first  of  month        job:  NewsletterSender        cron:  ‘0  0  0  1  *  ?’        process_tps_reports:        job:  TPSReportProcessor        cron:  ‘0  0  0  0  MON  ?’ Thursday, March 10, 2011
  • 84. Jobs “Fire  every  half  hour  from  10am  until  1pm   on  the  third  Friday  of  each  month” 0 */30 10-13 ? * FRI#3 Seconds Minutes Hours DOM Month DOW Year 1-7 1-12 1970- 1-31 SUN- 0-59 0-59 0-23 JAN- 2099 ?LW SAT DEC empty ?L# Thursday, March 10, 2011
  • 85. Jobs • More  portable.  What  is  the  first  day   of  the  week  on  BSD  again?    What’s   cron  on  Windows? • Self  contained  within  the  app.    No   external  systems  to  manage  and   keep  in  sync. • Full  rails  environment  loaded  and   available. Thursday, March 10, 2011
  • 86. Services run along, lil’ daemon Thursday, March 10, 2011
  • 87. Services Long-­running,  non-­web   “daemons”  that  share  the   runtime  environment  and   deployment  lifecycle  of   your  app. Thursday, March 10, 2011
  • 88. Services • Represented  as  a  class  with   optional  initialize(Hash),   start()  and  stop()  methods,   which  should  each  return  quickly. • Typically  will  start  a  long-­running   loop  in  a  thread  and  respond  to   external  events. • Configured  via  services:  section  in   torquebox.yml Thursday, March 10, 2011
  • 89. Services config/torquebox.yml services:    IrcBot:        server:  freenode.net        channel:  #torquebox        publish:  /topics/irc    MyMudServer:    SomeOtherService: Thursday, March 10, 2011
  • 90. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end end Thursday, March 10, 2011
  • 91. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end end Thursday, March 10, 2011
  • 92. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end end Thursday, March 10, 2011
  • 93. Services app/services/my_service.rb class  MyService    def  initialize(opts={})        name  =  opts[:publish]        @queue  =  Queue.new(name)    end    def  start          Thread.new  {  run  }      end    def  stop          @done  =  true    end end Thursday, March 10, 2011
  • 94. Services app/services/my_service.rb class  MyService    def  run        until  @done            @queue.publish(Time.now)            sleep(1)          end    end end Thursday, March 10, 2011
  • 95. Services app/services/my_service.rb class  MyService    def  run        until  @done            @queue.publish(Time.now)            sleep(1)          end    end end Thursday, March 10, 2011
  • 96. Clustering less failure faster Thursday, March 10, 2011
  • 97. out-­of-­the-­box • JBoss  provides • session  replication • load-­balanced  messaging • mod_cluster  provides • session  affinity • intelligent  load-­balanced  web • failover Thursday, March 10, 2011
  • 98. mod_cluster A  reverse  proxy  implemented   as  an  Apache  module  with   JBoss  awareness.  Constantly   gathers  load  statistics  and   deployment  availability  for   intelligent  request  distribution. Thursday, March 10, 2011
  • 100. mod_cluster • Dynamic  configuration • Server-­side  load  factor  calculation • Fine-­grained  web  app  lifecycle • AJP  (Apache  JServ  Protocol)  is   optional.  HTTP[S]  is  also  supported. Thursday, March 10, 2011
  • 101. Caching hot off of the press! Thursday, March 10, 2011
  • 102. Caching • Infinispan  cache  store • non-­clustered: • local • clustered: • invalidation • replicated • distributed Thursday, March 10, 2011
  • 103. Caching config/application.rb config.cache_store  =   :torque_box_store,  :mode  =>  :local #  or config.cache_store  =   ActiveSupport::Cache::TorqueBoxStore.new (  :mode  =>  :local  ) Thursday, March 10, 2011
  • 104. Other  Cool  Stuff well, we think it’s cool Thursday, March 10, 2011
  • 105. Cool  Stuff • StompBox  -­  git  based  deploys • BackStage  -­  see  behind  the  curtain • Built  in  authentication • Benchmarking/speed  improvements Thursday, March 10, 2011
  • 106. Live  Demo wish me luck Thursday, March 10, 2011
  • 107. Resources • http://torquebox.org • #torquebox  on  freenode • https://github.com/torquebox • http://twitter.com/torquebox • http://projectodd.org • https://github.com/tobias/ torquebox_rails_sample Thursday, March 10, 2011
  • 108. Thanks! questions? Thursday, March 10, 2011