26. Easy Install
(download 1.1 from torquebox.org)
$ unzip torquebox-dist-1.0.0.CR1-bin.zip
Make sure the jruby
found in your path is in
$ export TORQUEBOX_HOME=$PWD/torquebox-1*
$JRUBY_HOME/bin.
$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss
$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby
$ export PATH=$JRUBY_HOME/bin:$PATH
27. Easy Install
(download 1.1 from torquebox.org)
$ unzip torquebox-dist-1.0.0.CR1-bin.zip
Make sure the jruby
found in your path is in
$ export TORQUEBOX_HOME=$PWD/torquebox-1*
$JRUBY_HOME/bin.
$ export JBOSS_HOME=$TORQUEBOX_HOME/jboss
$ export JRUBY_HOME=$TORQUEBOX_HOME/jruby
$ export PATH=$JRUBY_HOME/bin:$PATH
28. Deployment
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
35. Web (Session Integration)
public class SomeServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse resp) {
request.getSession().getValue("password");;
}
}
37. mod_cluster
A reverse proxy implemented as
an Apache module with JBoss
awareness.
Constantly gathers load statistics
and deployment availability for
intelligent request distribution.
58. Queues
contrived example
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 )
59. Queues
contrived example
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 )
60. Queues
contrived example
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 )
61. Queues
contrived example
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 )
62. Queues
“on the fly”
include TorqueBox::Messaging
queue = Queue.new('/queues/foo')
queue.create
...
queue.destroy
63. 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 TorqueBox::Messaging::Topic
66. 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.
82. CDI Injection
class MyService
include TorqueBox::Injectors
def initialize opts={}
@thing = inject(com.mycorp.Something)
end
end
83. But there's more than
just CDI you can inject.
There's also queues,
topics, heroin and other
things.
84. Destination Injection
class MyService
include TorqueBox::Injectors
def initialize opts={}
@inbound = inject("/topics/questions")
@outbound = inject("/queues/answers")
end
end
85. JNDI Injection
class MyService
include TorqueBox::Injectors
def initialize opts={}
@factory = inject("java:comp/env/jdbc/myDS")
end
end
101. Thanks!
Questions?
Image attributions:
Target by Jasper Johns by nostri-imago http://www.flickr.com/photos/nostri-imago/3137422976/ CC BY 2.0
WEB 2.0 HAS AN API by raster http://www.flickr.com/photos/raster/137506981/ CC BY-NC-SA 2.0
Clock by Earls37a http://www.flickr.com/photos/indraw/4857101224/ CC BY-SA 2.0
Sink. by _Fidelio_ http://www.flickr.com/photos/photogaby/4129740673/ CC BY 2.0
Huge Queue 1 by danacea http://www.flickr.com/photos/danacea/2981199996/ CC BY-NC 2.0
Service as a Strategy Celebration at NCVS 2011 by Be The Change, Inc http://www.flickr.com/photos/bethechangeinc/5816393052/ CC BY-NC 2.0
Cash by ROSS HONG KONG http://www.flickr.com/photos/rossap/2716531616/ CC BY-NC-SA 2.0
Injection by Dr Case http://www.flickr.com/photos/justin_case/3252846177/ CC BY-NC 2.0
IMG_1478 by akshaydavis http://www.flickr.com/photos/akshaydavis/166391476/ CC BY-NC-SA 2.0
Rainforest by Chris.Gray http://www.flickr.com/photos/chriscgray/3946304802/ CC BY-NC-SA 2.0
Community by niallkennedy http://www.flickr.com/photos/niallkennedy/40727794/ CC BY-NC 2.0