The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack...

58
The Polyglot Future of JBoss AS Toby Crawley Red Hat, Inc.

Transcript of The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack...

Page 1: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

The Polyglot Future of JBoss AS

Toby CrawleyRed Hat, Inc.

Page 2: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

The Polyglot Future of JBoss AS

Toby CrawleyRed Hat, Inc.

Present

Page 3: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Yours Truly• Senior SW Engineer at Red Hat• Core developer on TorqueBox &

Immutant• Member of Project:Odd• @tcrawley

Page 4: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Agenda• intro• JBoss AS• JRuby & TorqueBox• Clojure & Immutant• crap, a demo• outro

Page 5: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST
Page 6: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

JBoss AS 7• Low memory footprint• Modularized class loader isolation• Fast startup time• Performant• EE6

Page 7: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

“Java is a DSL for taking large XML files and converting them to stack traces”

Scott Bellware

Page 8: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Goal

Leverage the AS as a platform to reduce some of the accidental complexity of your deployment

environment and allow you to use the best tool for the job.

Page 9: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Goal

To make you more productive.

Page 10: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Goal

To make you happy.

Page 11: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST
Page 12: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

• Expressive• Dynamic typing• Less ceremony• Makes you feel more cleverer

Ruby

Page 13: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Set<Person> people = new HashSet<Person>();

for ( Team each : teams ) { people.addAll( each.getMembers() );}

for ( Person each : people ) { each.promote();}

Page 14: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

teams. collect(&:members). flatten.uniq.each(&:promote!)

Page 15: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

JRuby• Real threads• Simple access to Java• Fastest Ruby implementation

Page 16: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

require 'java'

bar = org.projectodd.foo.Bar.newbar.a_value = 42bar.bazerize

Page 17: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST
Page 18: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

TorqueBox is an Application Server for Ruby built on top of JBoss AS7

Page 19: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

TorqueBoxCore

TorqueBoxCore

Java Virtual Machine

Managed Services ContainerJRuby with JIT

Security

Transactions

JBoss Web

Infinispan

HornetQ

Quartz

PicketLink

Rack

Sinatra Rails

Daemons

WebSocketsSTOMP

Tasks

Jobs

MessageProcessors

POJO

Spring

REST

JMS

Servlet

JavaEE

Messaging

Cache

Ruby!APIs!/!Programming!Models Java!APIs!/!Programming!Models

Polyglot Injection

Java!Enterprise!ServicesJRuby!Component!Deployers!&!Gems

Page 20: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Web

Supports any Rack framework (Rails, Sinata, Padrino, etc). Requests come in, responses go out. Works like you would expect...

Page 21: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Web

...but no war required. Just point TorqueBox at the application root.

Page 22: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Scheduled Jobs

Simple cron-like scheduling that shares your application's lifecycle.

Page 23: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Scheduled Jobs

class TPSReportJob

def run # work happens here end

end

Page 24: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Scheduled Jobs

TorqueBox.configure do

job TPSReportJob, :cron => '0 */5 * * * ?'

end

Page 25: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Backgroundable

Asynchronous execution with a simple api. Shares your application's lifecycle.

Page 26: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Backgroundableinclude TorqueBox::Messaging

class Userinclude Backgroundable

always_background :send_welcome

def send_welcome # slow email process end

end

Page 27: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging

Layered on top of JMS and HornetQ. Useful for decoupling or polyglot interop.

Page 28: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging

queue = inject( '/queue/morris_day' )

queue.publish( Time.now )

puts queue.receive

# Fri Dec 2 16:44:22 -0500 2011

Page 29: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaginginclude TorqueBox::Messaging

class TheTime < MessageProcessor

def on_message(body) # What time is it?!? puts body end

end

Page 30: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging

TorqueBox.configure do

queue '/queue/morris_day' do processor TheTime

end

end

Page 31: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Services

Long running daemons that share the application's lifecycle.

Page 32: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Injection

aka Inversion of Control. Telling the container what you need and letting it wire things up.

Page 33: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Distributed Transactions

True multi-resource distributed transactions.

Page 34: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Things I Skipped• Built-in WebSockets• Simple clustering• Key/Value store via Infinispan (Caching)

Page 35: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST
Page 36: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Clojure• Modern Lisp for the JVM• Functional• Immutable data• Concise syntax• Nice Java integration

Page 37: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Set<Person> people = new HashSet<Person>();

for ( Team each : teams ) { people.addAll( each.getMembers() );}

for ( Person each : people ) { each.promote();}

Page 38: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

(map promote! (set (extract :members teams)))

Page 39: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

(def extract mapcat)

(map promote! (set (extract :members teams)))

Page 40: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

(doto (org.projectodd.foo.Bar.) (.setAValue 42) (.bazerize))

Page 41: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Immutant

Page 42: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Immutant is an Application Server for Clojure being built on top of JBoss AS7

Page 43: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Web

Supports Ring handlers. Works like you would expect. Requests come in, responses go out. Endpoints can be created dynamically.

Page 44: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Web

(require '[immutant.web :as web])

(defn my-ring-handler [request] ;; process request here)

(web/start "/" my-ring-handler)...(web/stop "/")

Page 45: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging

Layered on top of JMS and HornetQ. Useful for decoupling or polyglot interop.

Page 46: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging(require '[immutant.messaging :as msg])

(def q "/queue/morris_day")

(msg/start q)

(msg/publish q (Date.))

(println (msg/receive q))

; #<Date Fri Dec 2 16:54:56 EST 2011>

Page 47: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Messaging

(msg/listen "/queue/morris_day" (fn [body] ;; What time is it?!? (println body)))

Page 48: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Daemons

Long running daemons that share the application's lifecycle.

Page 49: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Coming Soon• Scheduled Jobs• Distributed futures• Distributed state• Multi-resource transactions• Injection• You tell us!

Page 50: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

http://www.flickr.com/photos/-lucaslove/5084345964/

Page 51: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

http://www.flickr.com/photos/jdgoring/179412740/

Page 52: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Clojuretwitter

queue

daemon

Ruby

processor

Java

TweetClassifier

topicwebsockets you!

and you!

and you?

Page 53: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Language LOC

Ruby ~110

Clojure ~50

Java ~30

Javascript ~25

Page 54: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Availability• TorqueBox: 2.0.0.beta1 released today• Immutant: incremental builds available

Page 55: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Availability• TorqueBox: 2.0.0.beta1 released today• Immutant: incremental builds available

Monday

Page 56: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

http://www.flickr.com/photos/daveynin/4194763701/

Page 57: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

Resources• http://torquebox.org• #torquebox on freenode• @torquebox• http://immutant.org• #immutant on freenode• @immutants

Page 58: The Polyglot Future of JBoss AS - Toby CrawleyJBoss Web Infinispan HornetQ Quartz PicketLink Rack Sinatra Rails Daemons WebSockets STOMP Tasks Jobs Message Processors POJO Spring REST

http://www.flickr.com/photos/thaths/3760407774/