Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Torquebox - O melhor dos dois mundos

3,570 views

Published on

Published in: Technology
  • Be the first to comment

Torquebox - O melhor dos dois mundos

  1. 1. O melhor dos dois mundos Creative  Commons  BY-­SA  3.0Saturday, July 23, 2011
  2. 2. @abstractj Java há 12 anos, Ruby n00b TorqueBox Contributor Instrutor CaelumSaturday, July 23, 2011
  3. 3. DISCLAIMERSaturday, July 23, 2011
  4. 4. Java Come to the dark sideSaturday, July 23, 2011
  5. 5. ENTERPRISESaturday, July 23, 2011
  6. 6. JAXR Java-FX JAXP JSTL StAX JME JDOM JVM JAX-RPC EJB AWT JMX Swing EAR Struts JAAS JCP JavaBean NPE Spring JAX-WS ENTERPRISE RMI JSE JNI JEE SOA NIO JSP JSF JAXB WAR JNDI JDO JAX-RS JPQL EJBQL JAF POJO JRESaturday, July 23, 2011
  7. 7. Saturday, July 23, 2011
  8. 8. Mas escala né?!Saturday, July 23, 2011
  9. 9. Server SideSaturday, July 23, 2011
  10. 10. JBoss Tomcat + Infinispan + HornetQ + Quartz + ClusteringSaturday, July 23, 2011
  11. 11. Hot DeploymentSaturday, July 23, 2011
  12. 12. Scala Clojure Python JVM Ruby JavaScript GroovySaturday, July 23, 2011
  13. 13. Ruby Mais expressiva que JavaSaturday, July 23, 2011
  14. 14. DRYSaturday, July 23, 2011
  15. 15. JRuby Java + RubySaturday, July 23, 2011
  16. 16. “You get true multithreading that can use all your computer’s cores from one process, plus a virtual machine that’s been tuned for a decade and a half.” Using JRuby - Bringing Ruby to JavaSaturday, July 23, 2011
  17. 17. TorqueBox “The power of JBoss with the expressiveness of Ruby” Jim Crossley - MagicRuby ConferenceSaturday, July 23, 2011
  18. 18. TorqueBoxSaturday, July 23, 2011
  19. 19. Instalação TorqueBox do zeroSaturday, July 23, 2011
  20. 20. ➜ jruby -S gem install torquebox torquebox-capistrano-supportSaturday, July 23, 2011
  21. 21. ➜ wget http://torquebox.org/builds/LATEST/torquebox-dist- bin.zip ➜ unzip torquebox-dist-bin.zip ➜ export TORQUEBOX_HOME=$PWD/torquebox-1.x ➜ export JBOSS_HOME=$TORQUEBOX_HOME/jboss ➜ export JRUBY_HOME=$TORQUEBOX_HOME/jruby ➜ export PATH=$JRUBY_HOME/bin:$PATHSaturday, July 23, 2011
  22. 22. Estrutura Diretórios do TorqueBoxSaturday, July 23, 2011
  23. 23. Rails rails new bazinga -m $TORQUEBOX_HOME/share/rails/template.rbSaturday, July 23, 2011
  24. 24. Rake tasks rake torquebox:deploy rake torquebox:undeploy rake torquebox:runSaturday, July 23, 2011
  25. 25. Deployment Make knobs, not WAR!Saturday, July 23, 2011
  26. 26. bazinga-knob.yml application: root: /home/bruno/app/bazinga env: developmentSaturday, July 23, 2011
  27. 27. Scheduling Agendamento de JobsSaturday, July 23, 2011
  28. 28. ../app/jobs class JobDemo def initialize #Codigo de inicializacao end def run # O que você quer executar end endSaturday, July 23, 2011
  29. 29. ../config/torquebox.yml jobs: sync_agenda: job: JobDemo cron: 0 0 12 * * ? endSaturday, July 23, 2011
  30. 30. Mensageria Java Messaging Service + HornetQSaturday, July 23, 2011
  31. 31. Tasks class EmailerTask < TorqueBox::Messaging::Task def send_welcome(payload) to = "#{payload[:name]} <#{payload[:address]}>" # send welcome email to the user end endSaturday, July 23, 2011
  32. 32. Tasks class UserController < ApplicationController def register user = User.new(params[:user]) EmailerTask.async(:send_welcome, :address => user.email, :name => user.name) end endSaturday, July 23, 2011
  33. 33. messaging.yml /topics/print: PrintHandler /queues/students: PrintHandler: config: color: trueSaturday, July 23, 2011
  34. 34. Processors include TorqueBox::Messaging class PrintHandler < MessageProcessor   def on_message(body)     puts "Processing #{body} of #{message}"   end   def configure(opts)     @color = opts[color]   end endSaturday, July 23, 2011
  35. 35. Queues include TorqueBox req = Messaging::Queue.new /queues/questions res = Messaging::Queue.new /queues/answers   Thread.new do   req.publish "What time is it?"   puts res.receive( :timeout => 1000 ) end   puts req.receive res.publish Time.nowSaturday, July 23, 2011
  36. 36. ServiçosSaturday, July 23, 2011
  37. 37. class BazingaService def initialize @queue = Messaging::Queue.new(“bazinga”) end def start @queue.publish “Testing” end def stop # O que fazer quando o serviço receber um stop end endSaturday, July 23, 2011
  38. 38. CDI - Simplificado Injeção de dependênciasSaturday, July 23, 2011
  39. 39. Java package com.gurusp; public class Bazinga { //gets e sets public void say(String message) { // Execução do método } } Deploy do jar na aplicação app/ models/ views/ controllers/ lib/bazinga.jarSaturday, July 23, 2011
  40. 40. Ruby class BazingaController < ApplicationController include TorqueBox::Injectors def create bazinga = inject(com.gurusp.Bazinga ) bazinga.say “Ruby is for Java” end endSaturday, July 23, 2011
  41. 41. Caching class BeersController < ApplicationController caches_action :most_popular, :expires_in => 30.seconds def most_popular @popular_beers = Beer.most_popular(:limit => 25) end endSaturday, July 23, 2011
  42. 42. Saturday, July 23, 2011
  43. 43. Clustering ➜ $JBOSS_HOME/bin/run.sh -c allSaturday, July 23, 2011
  44. 44. Cache distribuído!Saturday, July 23, 2011
  45. 45. BackStageSaturday, July 23, 2011
  46. 46. Comunidade irc.freenode.net #torquebox http://torquebox.org http://github.com/torquebox twitter: @torqueboxSaturday, July 23, 2011
  47. 47. Obrigado! @abstractj Creative  Commons  BY-­SA  3.0Saturday, July 23, 2011

×