SlideShare une entreprise Scribd logo
1  sur  42
Télécharger pour lire hors ligne
Extending the
                           Java Message Service
                               to Web devices
                          over HTML5 WebSockets



Chris Barrow, Peter Moskovits
Kaazing Corporation
JavaOne - October 5, 2011

1     JavaOne 2011              © 2011 – Kaazing Corporation
Agenda


    l    HTML5 WebSockets vs. HTTP
    l    Java Message Service
    l    Implementing JMS over WebSockets
    l    Demos and code examples
    l    Kaazing WebSocket Gateway, JMS Edition
    l    Questions




2          JavaOne 2011    © 2011 – Kaazing Corporation
Networked Applications

                                                        Full duplex

TCP socket
                    Thick Client                                      Back-end
                                                                       server




 3   JavaOne 2011                  © 2011 – Kaazing Corporation
Networked Applications

                                                            Full duplex

TCP socket
                    Thick Client                                                       Back-end
                                                                                        server




                                                                                Full duplex
                                   Half Duplex



HTTP
                     Browser
                                                                          Middleware   Back-end
                                                                                        server




 4   JavaOne 2011                      © 2011 – Kaazing Corporation
HTTP Workarounds & Hacks

                                                                                 Full duplex
                              Half Duplex




                    Browser
                                                                           Middleware   Back-end
                                                                                         server




 5   JavaOne 2011                           © 2011 – Kaazing Corporation
HTML5 WebSocket

 l    Extends TCP across the web
       l    Full-duplex, single socket, very low overhead
       l    Shares port with HTTP (80/443)
         Enables new classes of networked apps
       l 


 l    W3C API (JavaScript)
 l    IETF Protocol

                                                           Full duplex



WebSocket
                            Browser                                      Back-end
                                                                          server
  6          JavaOne 2011             © 2011 – Kaazing Corporation
HTTP vs. WebSocket




                          HTTP                                      WebSocket
 Overhead                 1000s of bytes (headers)                  2-6 bytes/frame (typical)
 Latency                  New connection each time None: Reuses existing
                                                   connection
 Latency (polling)        Must wait for next request                No waiting
 Latency (long polling)   None, if server is holding                No waiting
                          a pending request (+ time
                          to set up new connection)




 7      JavaOne 2011                 © 2011 – Kaazing Corporation
Overheard…

     "Reducing kilobytes of data to 2 bytes… and
     reducing latency from 150ms to 50ms is far more
     than marginal. In fact, these two factors alone are
     enough to make WebSocket seriously interesting to
     Google."

     Ian Hickson (Google, HTML5 Spec Lead)




 8      JavaOne 2011          © 2011 – Kaazing Corporation
Using the WebSocket API

     Java

     //Create and connect new WebSocket
     WebSocket mySocket = new WebSocket();

     // Associate listener
     webSocket.addWebSocketListener(
        new WebSocketListener() {

             @Override
             public void onMessage(WebSocketEvent event) {
               alert(event.getData());
             }

             @Override
             public void onClose(WebSocketEvent closedEvent) {}
       };

     mySocket.connect(new URI("ws://www.WebSocket.org"));
     mySocket.send("Hello world!");

 9          JavaOne 2011           © 2011 – Kaazing Corporation
WebSocket Browser Support

Browser native support
      §    Chrome
      §    Firefox (need to turn on)
      §    Opera 10.7 (need to turn on)
      §    Safari
      §    Internet Explorer 9+ Beta




 10         JavaOne 2011                © 2011 – Kaazing Corporation
JMS Over WebSocket

                                 WebSocket




                     Browser                                  Back-end
                                                               server




 11   JavaOne 2011             © 2011 – Kaazing Corporation
JMS Over WebSocket

                                 WebSocket




                     Browser                                  Back-end
                                                               server




                                     JMS

                                 WebSocket




                     Browser                                  Back-end
                                                               server

 12   JavaOne 2011             © 2011 – Kaazing Corporation
Java Message Service



13   JavaOne 2011   © 2011 – Kaazing Corporation
Why JMS?

  l    WebSocket is a good start but doesn't offer
        much help to the application developer
  l    JMS well established standard, widely available
  l    Offers important features over pure WebSocket:
        l      Publish and subscribe (Topics) for broadcast
        l      Point to point (Queues) for command processing
        l      Transactions
        l      Guaranteed delivery
        l      Structured data


 14           JavaOne 2011            © 2011 – Kaazing Corporation
Why JMS over WebSocket?
Typical Current JMS Architecture
                        Firewall
                                          J2EE	
  Applica+on	
  Server	
  

                                   Web Container               EJB Container
          SOAP over HTTP                                                           JMS
                                       Web
                                      Service                           EJB

                      WEB
                                       JSP
                                                                                     Message Broker
                      HTTP                                                           (JMS Provider)




  15   JavaOne 2011                                 © 2011 – Kaazing Corporation
Why JMS over WebSocket?
Typical Current JMS Architecture
                        Firewall
                                          J2EE	
  Applica+on	
  Server	
  

                                   Web Container               EJB Container
          SOAP over HTTP                                                           JMS
                                       Web
                                      Service                           EJB

                      WEB
                                       JSP
                                                                                     Message Broker
                      HTTP                                                           (JMS Provider)



New WebSocket-based Architecture
                                                      Firewall

                 JMS Over
                 WebSocket




  16   JavaOne 2011                                 © 2011 – Kaazing Corporation
Implementing JMS over WebSockets




17   JavaOne 2011   © 2011 – Kaazing Corporation
JMS over WebSocket



  1. JMS Client library (in browser, web device)
  2. Protocol
  3. Server (bridge between broker & web)
  4. Message Broker (JMS Provider)




 18   JavaOne 2011       © 2011 – Kaazing Corporation
JMS Client Library

 ●    Implements the JMS objects and API
      l    Initiate WebSocket connection
      l    Encode outgoing JMS messages in STOMP
      l    Decode and deliver incoming messages
 ●    Manage connections and sessions, stop and
      start, message listeners, reconnect
 ●    A single WebSocket connection suffices
      (full duplex, asynchronous receive)




 19         JavaOne 2011            © 2011 – Kaazing Corporation
The Protocol

  l    STOMP
        l      Text-based wire encoding, so suitable for multiple
                client languages (Java, JavaScript, ...)
        l      http://stomp.codehaus.org             & http://stomp.github.com!
  l    Wireline encoding into STOMP:
        l      CONNECTnNAME:namen PASS:password (once)
        l      Encode JMS properties as key-value pairs:
                    SENDnprop1:valuenprop2
                   - 
                 -  MESSAGEnprop1:valuenprop2
        l      SUBSCRIBEndestination:/topic/stock
        l      BEGIN, COMMIT, ABORT
 20           JavaOne 2011          © 2011 – Kaazing Corporation
JMS Client Library

 ●    session.createConsumer
      l    → SUBSCRIBE destination:xxx
      l    Await RECEIPT
 ●    producer.send
      l    → SEND prop1:val1... <text>
      l    Await RECEIPT
 ●    Separate thread(s): read MESSAGE's
      l    Route to appropriate MessageListener
      l    Send ACK




 21         JavaOne 2011           © 2011 – Kaazing Corporation
JMS Client Library

 ●    Transactions
      l    Group message sends and Acks
      l    Single unit of work
 ●    Auto-reconnect
      l    For resilience to network failures
      l    Reissue SUBSCRIBEs
 ●    Other client languages:
      l    Javascript, Flash, .Net




 22         JavaOne 2011              © 2011 – Kaazing Corporation
The Server

 ●    Bridge between Web and Message Broker
      l    Accepts WebSocket connections
      l    Connects to JMS provider
 ●    Converts incoming STOMP frames to JMS API
      calls
 ●    Routes messages from provider back to clients
 ●    Must manage flow control




 23         JavaOne 2011           © 2011 – Kaazing Corporation
The Server

 l    Simplest implementation:
       l    Each client connection → 1 broker Connection and
             Session
       l    Each client subscription (message consumer) → 1
             consumer in broker
 l    More scalable:
       l    1 connection for many clients
       l    Single topic subscription for many clients




 24          JavaOne 2011         © 2011 – Kaazing Corporation
Demos

                                           http://portfolio.kaazing.me!




http://forex.kaazing.me!
25   JavaOne 2011          © 2011 – Kaazing Corporation
Portfolio Demo

 ●    "stock" topic for stock price updates
      l     MessageConsumer stockConsumer!
      l     MessageListener: portfolioModel.updateStock()!
 ●    Temporary queue for command responses
      l     responseQueue = session.createTemporaryQueue()!
 ●    "command" queue to send commands
      l     producer.send (replyTo=responseQueue)
      l     command property (get_portfolio, get_balance, buy, sell)




26          JavaOne 2011             © 2011 – Kaazing Corporation
Code Examples


     l    Creating a connection (omitting exception handling)
           env.put(Context.INITIAL_CONTEXT_FACTORY,	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  StompInitialContextFactory.class.getName());	
  
           env.put(Context.PROVIDER_URL,	
  “ws://myhost:80/stomp.jms”);	
  
           InitialContext	
  ctx	
  =	
  new	
  InitialContext(env);	
  
           ConnectionFactory	
  cf	
  =	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  (ConnectionFactory)ctx.lookup(“ConnectionFactory”);	
  
           Connection	
  connection	
  =	
  cf.createConnection();	
  

     l    Destination look up
           Topic	
  stockTopic	
  =	
  (Topic)ctx.lookup(“/topic/stock”);




27            JavaOne 2011                             © 2011 – Kaazing Corporation
Code Examples


     l    From there it's all just standard JMS API
           Session	
  session	
  =	
  connection.createSession(false,	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  Session.AUTO_ACKNOWLEDGE);	
  
           MessageConsumer	
  stockConsumer	
  =	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  session.createConsumer(stockTopic);	
  
           	
  
           //	
  Listen	
  for	
  stock	
  price	
  changes	
  
           stockConsumer.setMessageListener(new	
  MessageListener()	
  {	
  
           	
  	
  	
  	
  @Override	
  
           	
  	
  	
  	
  public	
  void	
  onMessage(Message	
  message)	
  {	
  
           	
  	
  	
  	
  	
  	
  	
  	
  try	
  {	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  String	
  stockData	
  =	
  ((TextMessage)message).getText();	
  
           	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  portfolioModel.updateStock(new	
  Stock(stockData));	
  
           	
  	
  	
  	
  	
  	
  	
  	
  }	
  
           	
  	
  	
  	
  	
  	
  	
  	
  catch(JMSException	
  e)	
  {	
  
           	
  	
  	
  	
  	
  	
  	
  	
  }	
  
           	
  	
  	
  	
  }	
  
           }	
  
           connection.start();	
  

28             JavaOne 2011                                      © 2011 – Kaazing Corporation
A Real World Solution:
     Kaazing WebSocket Gateway



29    JavaOne 2011   © 2011 – Kaazing Corporation
WebSocket Client Support



  l    Java and JavaFX
  l    JavaScript
  l    Microsoft Silverlight
        and .NET
  l    Adobe Flex (Flash)




 30       JavaOne 2011          © 2011 – Kaazing Corporation
WebSocket Emulation

Emulation for browsers with no native WebSocket support:
      l    Kaazing WebSocket Gateway: makes WebSocket work in all
            browsers today:
            l     Internet Explorer 6, 7, 8
            l     Firefox 3.6
            l     And more . . .




 31         JavaOne 2011                   © 2011 – Kaazing Corporation
Kaazing JMS Edition




  l    Messages traverse firewalls and proxies
  l    Fast, secure communication over the Internet
  l    Message distribution to massive numbers of clients
        thanks to resource offloading (fan-out)


 32       JavaOne 2011         © 2011 – Kaazing Corporation
Resource Offloading

 ●    Connection + Session offload (fan out)
      l     Reduces broker resource usage
      l     Minimal connections, sessions to broker
 ●    Java NIO (Apache Mina framework)
 ●    Subscription offload
      l     Multiplexed over shared connection, single message
             consumer
      l     Gateway tracks subscribed topics and queues from
             all connected clients
      l     Gateway handles individual client acknowledgments


33          JavaOne 2011         © 2011 – Kaazing Corporation
Resource Offloading




34   JavaOne 2011   © 2011 – Kaazing Corporation
JMS Gateway Features

 ●    “stomp.jms” service
      l     Clients speak STOMP to the service.
      l     Service uses vendor's JMS API to talk to broker
      l     Connection, session and subscription offload
 ●    “stomp.proxy” service
      l     Clients speak STOMP to the service
      l     Service uses STOMP to talk to “stomp.jms” service
             running on another Gateway
      l     Further offload
 ●    Gateway clusters for High Availability

35          JavaOne 2011         © 2011 – Kaazing Corporation
Using Multiple Gateways

 ●    Hundreds of thousands of clients or more can be
      supported by using a network of gateways
 ●    “stomp.proxy” gateways at the edge (near users)
      l     Route messages to central gateway running
             “stomp.jms” service
      l     Connection offloading (single connection to central
             gateway)
 ●    Most network traffic is local
 ●    Use gateway clusters for HA


36          JavaOne 2011         © 2011 – Kaazing Corporation
Using Multiple Gateways




37   JavaOne 2011   © 2011 – Kaazing Corporation
Writing Applications


     l    JMS API is available to code running within the browser
           or mobile device
     l    Gateway provides client libraries
     l    Written like a Java JMS client
     l    Similar concepts and APIs for each client technology
           (JavaScript, Flash, .Net)
     l    Application needs to include Kaazing JMS library files
           (jars, .js)




38          JavaOne 2011          © 2011 – Kaazing Corporation
Live Customer Application




39   JavaOne 2011   © 2011 – Kaazing Corporation
Take-aways


     l    HTML5 WebSockets offers a paradigm shift for highly
           interactive and scalable Web applications
     l    High level protocols can be extended beyond the
           firewall all the way to Web devices:
                l    JMS
                l    XMPP
                l    AMQP
     l    Production solution with live customers available today




40          JavaOne 2011          © 2011 – Kaazing Corporation
Conclusion


“We’re committed to providing real-time
access to critical management information
across the enterprise...

Kaazing solves the industry’s fundamental issues
which have kept yesterday’s web architecture
from meeting these needs.”


     Quintin Gomez, CTO of ITRS Group, 28 Sep 11




41   JavaOne 2011           © 2011 – Kaazing Corporation
Questions and Answers




42   JavaOne 2011   © 2011 – Kaazing
     Corporation

Contenu connexe

Tendances

What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)Pavel Bucek
 
Velocity 2012: The 90-Minute Mobile Optimization Life Cycle
Velocity 2012: The 90-Minute Mobile Optimization Life CycleVelocity 2012: The 90-Minute Mobile Optimization Life Cycle
Velocity 2012: The 90-Minute Mobile Optimization Life CycleStrangeloop
 
Dave Carroll Application Services Salesforce
Dave Carroll Application Services SalesforceDave Carroll Application Services Salesforce
Dave Carroll Application Services Salesforcedeimos
 
Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Bruno Borges
 
Seatwave Web Peformance Optimisation Case Study
Seatwave Web Peformance Optimisation Case StudySeatwave Web Peformance Optimisation Case Study
Seatwave Web Peformance Optimisation Case StudyStephen Thair
 
Performance Implications of Mobile Design
Performance Implications of Mobile DesignPerformance Implications of Mobile Design
Performance Implications of Mobile DesignGuy Podjarny
 
Contributing to OSS in a commercial non-OSS environment
Contributing to OSS in a commercial non-OSS environmentContributing to OSS in a commercial non-OSS environment
Contributing to OSS in a commercial non-OSS environmentFunambol
 
Developer Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer ExperienceDeveloper Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer ExperienceTasneem Sayeed
 
Top Ten Web Attacks
Top Ten Web Attacks Top Ten Web Attacks
Top Ten Web Attacks Ajay Ohri
 
Introduction To J Boss Seam
Introduction To J Boss SeamIntroduction To J Boss Seam
Introduction To J Boss Seamashishkulkarni
 
XML and Web Services with Groovy
XML and Web Services with GroovyXML and Web Services with Groovy
XML and Web Services with GroovyPaul King
 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Griddeimos
 
Web Quick Start with Tribloom: A tale of two wqs implementations
Web Quick Start with Tribloom: A tale of two wqs implementationsWeb Quick Start with Tribloom: A tale of two wqs implementations
Web Quick Start with Tribloom: A tale of two wqs implementationsAlfresco Software
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersSascha Corti
 

Tendances (18)

What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)What's next for Java API for WebSocket (JSR 356)
What's next for Java API for WebSocket (JSR 356)
 
Velocity 2012: The 90-Minute Mobile Optimization Life Cycle
Velocity 2012: The 90-Minute Mobile Optimization Life CycleVelocity 2012: The 90-Minute Mobile Optimization Life Cycle
Velocity 2012: The 90-Minute Mobile Optimization Life Cycle
 
Asif
AsifAsif
Asif
 
Dave Carroll Application Services Salesforce
Dave Carroll Application Services SalesforceDave Carroll Application Services Salesforce
Dave Carroll Application Services Salesforce
 
Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012Introducing WebLogic 12c OTN Tour 2012
Introducing WebLogic 12c OTN Tour 2012
 
Seatwave Web Peformance Optimisation Case Study
Seatwave Web Peformance Optimisation Case StudySeatwave Web Peformance Optimisation Case Study
Seatwave Web Peformance Optimisation Case Study
 
Performance Implications of Mobile Design
Performance Implications of Mobile DesignPerformance Implications of Mobile Design
Performance Implications of Mobile Design
 
Fuji Overview
Fuji OverviewFuji Overview
Fuji Overview
 
Contributing to OSS in a commercial non-OSS environment
Contributing to OSS in a commercial non-OSS environmentContributing to OSS in a commercial non-OSS environment
Contributing to OSS in a commercial non-OSS environment
 
Word camp nextweb
Word camp nextwebWord camp nextweb
Word camp nextweb
 
Windows Azure Essentials
Windows Azure EssentialsWindows Azure Essentials
Windows Azure Essentials
 
Developer Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer ExperienceDeveloper Pitfalls & Strategies for Improving Mobile Web Developer Experience
Developer Pitfalls & Strategies for Improving Mobile Web Developer Experience
 
Top Ten Web Attacks
Top Ten Web Attacks Top Ten Web Attacks
Top Ten Web Attacks
 
Introduction To J Boss Seam
Introduction To J Boss SeamIntroduction To J Boss Seam
Introduction To J Boss Seam
 
XML and Web Services with Groovy
XML and Web Services with GroovyXML and Web Services with Groovy
XML and Web Services with Groovy
 
Brian Oliver Pimp My Data Grid
Brian Oliver  Pimp My Data GridBrian Oliver  Pimp My Data Grid
Brian Oliver Pimp My Data Grid
 
Web Quick Start with Tribloom: A tale of two wqs implementations
Web Quick Start with Tribloom: A tale of two wqs implementationsWeb Quick Start with Tribloom: A tale of two wqs implementations
Web Quick Start with Tribloom: A tale of two wqs implementations
 
HTML5 Intoduction for Web Developers
HTML5 Intoduction for Web DevelopersHTML5 Intoduction for Web Developers
HTML5 Intoduction for Web Developers
 

Similaire à Extending JMS to Web Devices over HTML5 WebSockets - JavaOne 2011

HTML5 WebSocket Introduction
HTML5 WebSocket IntroductionHTML5 WebSocket Introduction
HTML5 WebSocket IntroductionMarcelo Jabali
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)Peter Lubbers
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Arun Gupta
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaJAX London
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCamelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCharles Moulliard
 
Oop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXFOop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXFAdrian Trenaman
 
HTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebHTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebDominique Guinard
 
Enterprise Java in 2012 and Beyond, by Juergen Hoeller
Enterprise Java in 2012 and Beyond, by Juergen Hoeller Enterprise Java in 2012 and Beyond, by Juergen Hoeller
Enterprise Java in 2012 and Beyond, by Juergen Hoeller Codemotion
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01purans
 
The Top 10 Business Reasons for 10GbE iSCSI
The Top 10 Business Reasons for 10GbE iSCSIThe Top 10 Business Reasons for 10GbE iSCSI
The Top 10 Business Reasons for 10GbE iSCSIEmulex Corporation
 

Similaire à Extending JMS to Web Devices over HTML5 WebSockets - JavaOne 2011 (20)

HTML5 WebSocket Introduction
HTML5 WebSocket IntroductionHTML5 WebSocket Introduction
HTML5 WebSocket Introduction
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
 
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
Building HTML5 WebSocket Apps in Java at JavaOne Latin America 2012
 
Websocket 1.0
Websocket 1.0Websocket 1.0
Websocket 1.0
 
HTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun GuptaHTML5 Websockets and Java - Arun Gupta
HTML5 Websockets and Java - Arun Gupta
 
Jetty Vs Tomcat
Jetty Vs TomcatJetty Vs Tomcat
Jetty Vs Tomcat
 
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/CamelCamelone-2012 HTML5 WebSocket ActiveMQ/Camel
Camelone-2012 HTML5 WebSocket ActiveMQ/Camel
 
Java EE 7 - Overview and Status
Java EE 7  - Overview and StatusJava EE 7  - Overview and Status
Java EE 7 - Overview and Status
 
Jspx Jdc2010
Jspx Jdc2010Jspx Jdc2010
Jspx Jdc2010
 
Jax2010 adobe lcds
Jax2010 adobe lcdsJax2010 adobe lcds
Jax2010 adobe lcds
 
Oop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXFOop2008 RESTful services with GWT and Apache CXF
Oop2008 RESTful services with GWT and Apache CXF
 
HTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile WebHTML5, Websockets & the Mobile Web
HTML5, Websockets & the Mobile Web
 
Enterprise Java in 2012 and Beyond, by Juergen Hoeller
Enterprise Java in 2012 and Beyond, by Juergen Hoeller Enterprise Java in 2012 and Beyond, by Juergen Hoeller
Enterprise Java in 2012 and Beyond, by Juergen Hoeller
 
Sail Fin Webinar Overview
Sail Fin Webinar OverviewSail Fin Webinar Overview
Sail Fin Webinar Overview
 
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
Jwebsocketmobiletechcon2010en 100912071225 Phpapp01
 
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerryjWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
jWebSocket MobileTechCon 2010 - WebSockets on Android, Symbian and BlackBerry
 
J web socket
J web socketJ web socket
J web socket
 
WebSockets - Boosting Web Communication - SDC 2011
WebSockets - Boosting Web Communication - SDC 2011WebSockets - Boosting Web Communication - SDC 2011
WebSockets - Boosting Web Communication - SDC 2011
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
The Top 10 Business Reasons for 10GbE iSCSI
The Top 10 Business Reasons for 10GbE iSCSIThe Top 10 Business Reasons for 10GbE iSCSI
The Top 10 Business Reasons for 10GbE iSCSI
 

Plus de Peter Moskovits

Connecting Physical Devices to the Web - Event Driven Architecture using WebS...
Connecting Physical Devices to the Web - Event Driven Architecture using WebS...Connecting Physical Devices to the Web - Event Driven Architecture using WebS...
Connecting Physical Devices to the Web - Event Driven Architecture using WebS...Peter Moskovits
 
HTML5 WebSocket for the Real-Time Web and the Internet of Things
HTML5 WebSocket for the Real-Time Weband the Internet of ThingsHTML5 WebSocket for the Real-Time Weband the Internet of Things
HTML5 WebSocket for the Real-Time Web and the Internet of ThingsPeter Moskovits
 
Liberating the Black Box - Real-Time Communications for the Internet of Things
Liberating the Black Box - Real-Time Communications for the Internet of ThingsLiberating the Black Box - Real-Time Communications for the Internet of Things
Liberating the Black Box - Real-Time Communications for the Internet of ThingsPeter Moskovits
 
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...Peter Moskovits
 
WebGL and Real-Time Web Communication
WebGL and Real-Time Web CommunicationWebGL and Real-Time Web Communication
WebGL and Real-Time Web CommunicationPeter Moskovits
 
Building Real-Time Enterprise Applications for the Internet of Things
Building Real-Time Enterprise Applications for the Internet of ThingsBuilding Real-Time Enterprise Applications for the Internet of Things
Building Real-Time Enterprise Applications for the Internet of ThingsPeter Moskovits
 
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...Peter Moskovits
 
Goo technologies pres sfhtml5_v1_130529
Goo technologies pres sfhtml5_v1_130529Goo technologies pres sfhtml5_v1_130529
Goo technologies pres sfhtml5_v1_130529Peter Moskovits
 
Ore dev2011 kaazing_websockets
Ore dev2011 kaazing_websocketsOre dev2011 kaazing_websockets
Ore dev2011 kaazing_websocketsPeter Moskovits
 

Plus de Peter Moskovits (9)

Connecting Physical Devices to the Web - Event Driven Architecture using WebS...
Connecting Physical Devices to the Web - Event Driven Architecture using WebS...Connecting Physical Devices to the Web - Event Driven Architecture using WebS...
Connecting Physical Devices to the Web - Event Driven Architecture using WebS...
 
HTML5 WebSocket for the Real-Time Web and the Internet of Things
HTML5 WebSocket for the Real-Time Weband the Internet of ThingsHTML5 WebSocket for the Real-Time Weband the Internet of Things
HTML5 WebSocket for the Real-Time Web and the Internet of Things
 
Liberating the Black Box - Real-Time Communications for the Internet of Things
Liberating the Black Box - Real-Time Communications for the Internet of ThingsLiberating the Black Box - Real-Time Communications for the Internet of Things
Liberating the Black Box - Real-Time Communications for the Internet of Things
 
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...
Controlling Physical Devices on the Real-Time Web: Enterprise-Grade WebSocket...
 
WebGL and Real-Time Web Communication
WebGL and Real-Time Web CommunicationWebGL and Real-Time Web Communication
WebGL and Real-Time Web Communication
 
Building Real-Time Enterprise Applications for the Internet of Things
Building Real-Time Enterprise Applications for the Internet of ThingsBuilding Real-Time Enterprise Applications for the Internet of Things
Building Real-Time Enterprise Applications for the Internet of Things
 
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
JMS, WebSocket, and the Internet of Things - Controlling Physical Devices on ...
 
Goo technologies pres sfhtml5_v1_130529
Goo technologies pres sfhtml5_v1_130529Goo technologies pres sfhtml5_v1_130529
Goo technologies pres sfhtml5_v1_130529
 
Ore dev2011 kaazing_websockets
Ore dev2011 kaazing_websocketsOre dev2011 kaazing_websockets
Ore dev2011 kaazing_websockets
 

Dernier

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 

Dernier (20)

WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
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
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 

Extending JMS to Web Devices over HTML5 WebSockets - JavaOne 2011

  • 1. Extending the Java Message Service to Web devices over HTML5 WebSockets Chris Barrow, Peter Moskovits Kaazing Corporation JavaOne - October 5, 2011 1 JavaOne 2011 © 2011 – Kaazing Corporation
  • 2. Agenda l  HTML5 WebSockets vs. HTTP l  Java Message Service l  Implementing JMS over WebSockets l  Demos and code examples l  Kaazing WebSocket Gateway, JMS Edition l  Questions 2 JavaOne 2011 © 2011 – Kaazing Corporation
  • 3. Networked Applications Full duplex TCP socket Thick Client Back-end server 3 JavaOne 2011 © 2011 – Kaazing Corporation
  • 4. Networked Applications Full duplex TCP socket Thick Client Back-end server Full duplex Half Duplex HTTP Browser Middleware Back-end server 4 JavaOne 2011 © 2011 – Kaazing Corporation
  • 5. HTTP Workarounds & Hacks Full duplex Half Duplex Browser Middleware Back-end server 5 JavaOne 2011 © 2011 – Kaazing Corporation
  • 6. HTML5 WebSocket l  Extends TCP across the web l  Full-duplex, single socket, very low overhead l  Shares port with HTTP (80/443) Enables new classes of networked apps l  l  W3C API (JavaScript) l  IETF Protocol Full duplex WebSocket Browser Back-end server 6 JavaOne 2011 © 2011 – Kaazing Corporation
  • 7. HTTP vs. WebSocket HTTP WebSocket Overhead 1000s of bytes (headers) 2-6 bytes/frame (typical) Latency New connection each time None: Reuses existing connection Latency (polling) Must wait for next request No waiting Latency (long polling) None, if server is holding No waiting a pending request (+ time to set up new connection) 7 JavaOne 2011 © 2011 – Kaazing Corporation
  • 8. Overheard… "Reducing kilobytes of data to 2 bytes… and reducing latency from 150ms to 50ms is far more than marginal. In fact, these two factors alone are enough to make WebSocket seriously interesting to Google." Ian Hickson (Google, HTML5 Spec Lead) 8 JavaOne 2011 © 2011 – Kaazing Corporation
  • 9. Using the WebSocket API Java //Create and connect new WebSocket WebSocket mySocket = new WebSocket(); // Associate listener webSocket.addWebSocketListener( new WebSocketListener() { @Override public void onMessage(WebSocketEvent event) { alert(event.getData()); } @Override public void onClose(WebSocketEvent closedEvent) {} }; mySocket.connect(new URI("ws://www.WebSocket.org")); mySocket.send("Hello world!"); 9 JavaOne 2011 © 2011 – Kaazing Corporation
  • 10. WebSocket Browser Support Browser native support §  Chrome §  Firefox (need to turn on) §  Opera 10.7 (need to turn on) §  Safari §  Internet Explorer 9+ Beta 10 JavaOne 2011 © 2011 – Kaazing Corporation
  • 11. JMS Over WebSocket WebSocket Browser Back-end server 11 JavaOne 2011 © 2011 – Kaazing Corporation
  • 12. JMS Over WebSocket WebSocket Browser Back-end server JMS WebSocket Browser Back-end server 12 JavaOne 2011 © 2011 – Kaazing Corporation
  • 13. Java Message Service 13 JavaOne 2011 © 2011 – Kaazing Corporation
  • 14. Why JMS? l  WebSocket is a good start but doesn't offer much help to the application developer l  JMS well established standard, widely available l  Offers important features over pure WebSocket: l  Publish and subscribe (Topics) for broadcast l  Point to point (Queues) for command processing l  Transactions l  Guaranteed delivery l  Structured data 14 JavaOne 2011 © 2011 – Kaazing Corporation
  • 15. Why JMS over WebSocket? Typical Current JMS Architecture Firewall J2EE  Applica+on  Server   Web Container EJB Container SOAP over HTTP JMS Web Service EJB WEB JSP Message Broker HTTP (JMS Provider) 15 JavaOne 2011 © 2011 – Kaazing Corporation
  • 16. Why JMS over WebSocket? Typical Current JMS Architecture Firewall J2EE  Applica+on  Server   Web Container EJB Container SOAP over HTTP JMS Web Service EJB WEB JSP Message Broker HTTP (JMS Provider) New WebSocket-based Architecture Firewall JMS Over WebSocket 16 JavaOne 2011 © 2011 – Kaazing Corporation
  • 17. Implementing JMS over WebSockets 17 JavaOne 2011 © 2011 – Kaazing Corporation
  • 18. JMS over WebSocket 1. JMS Client library (in browser, web device) 2. Protocol 3. Server (bridge between broker & web) 4. Message Broker (JMS Provider) 18 JavaOne 2011 © 2011 – Kaazing Corporation
  • 19. JMS Client Library ●  Implements the JMS objects and API l  Initiate WebSocket connection l  Encode outgoing JMS messages in STOMP l  Decode and deliver incoming messages ●  Manage connections and sessions, stop and start, message listeners, reconnect ●  A single WebSocket connection suffices (full duplex, asynchronous receive) 19 JavaOne 2011 © 2011 – Kaazing Corporation
  • 20. The Protocol l  STOMP l  Text-based wire encoding, so suitable for multiple client languages (Java, JavaScript, ...) l  http://stomp.codehaus.org & http://stomp.github.com! l  Wireline encoding into STOMP: l  CONNECTnNAME:namen PASS:password (once) l  Encode JMS properties as key-value pairs: SENDnprop1:valuenprop2 -  -  MESSAGEnprop1:valuenprop2 l  SUBSCRIBEndestination:/topic/stock l  BEGIN, COMMIT, ABORT 20 JavaOne 2011 © 2011 – Kaazing Corporation
  • 21. JMS Client Library ●  session.createConsumer l  → SUBSCRIBE destination:xxx l  Await RECEIPT ●  producer.send l  → SEND prop1:val1... <text> l  Await RECEIPT ●  Separate thread(s): read MESSAGE's l  Route to appropriate MessageListener l  Send ACK 21 JavaOne 2011 © 2011 – Kaazing Corporation
  • 22. JMS Client Library ●  Transactions l  Group message sends and Acks l  Single unit of work ●  Auto-reconnect l  For resilience to network failures l  Reissue SUBSCRIBEs ●  Other client languages: l  Javascript, Flash, .Net 22 JavaOne 2011 © 2011 – Kaazing Corporation
  • 23. The Server ●  Bridge between Web and Message Broker l  Accepts WebSocket connections l  Connects to JMS provider ●  Converts incoming STOMP frames to JMS API calls ●  Routes messages from provider back to clients ●  Must manage flow control 23 JavaOne 2011 © 2011 – Kaazing Corporation
  • 24. The Server l  Simplest implementation: l  Each client connection → 1 broker Connection and Session l  Each client subscription (message consumer) → 1 consumer in broker l  More scalable: l  1 connection for many clients l  Single topic subscription for many clients 24 JavaOne 2011 © 2011 – Kaazing Corporation
  • 25. Demos http://portfolio.kaazing.me! http://forex.kaazing.me! 25 JavaOne 2011 © 2011 – Kaazing Corporation
  • 26. Portfolio Demo ●  "stock" topic for stock price updates l  MessageConsumer stockConsumer! l  MessageListener: portfolioModel.updateStock()! ●  Temporary queue for command responses l  responseQueue = session.createTemporaryQueue()! ●  "command" queue to send commands l  producer.send (replyTo=responseQueue) l  command property (get_portfolio, get_balance, buy, sell) 26 JavaOne 2011 © 2011 – Kaazing Corporation
  • 27. Code Examples l  Creating a connection (omitting exception handling) env.put(Context.INITIAL_CONTEXT_FACTORY,                      StompInitialContextFactory.class.getName());   env.put(Context.PROVIDER_URL,  “ws://myhost:80/stomp.jms”);   InitialContext  ctx  =  new  InitialContext(env);   ConnectionFactory  cf  =                        (ConnectionFactory)ctx.lookup(“ConnectionFactory”);   Connection  connection  =  cf.createConnection();   l  Destination look up Topic  stockTopic  =  (Topic)ctx.lookup(“/topic/stock”); 27 JavaOne 2011 © 2011 – Kaazing Corporation
  • 28. Code Examples l  From there it's all just standard JMS API Session  session  =  connection.createSession(false,                                                  Session.AUTO_ACKNOWLEDGE);   MessageConsumer  stockConsumer  =                    session.createConsumer(stockTopic);     //  Listen  for  stock  price  changes   stockConsumer.setMessageListener(new  MessageListener()  {          @Override          public  void  onMessage(Message  message)  {                  try  {                          String  stockData  =  ((TextMessage)message).getText();                          portfolioModel.updateStock(new  Stock(stockData));                  }                  catch(JMSException  e)  {                  }          }   }   connection.start();   28 JavaOne 2011 © 2011 – Kaazing Corporation
  • 29. A Real World Solution: Kaazing WebSocket Gateway 29 JavaOne 2011 © 2011 – Kaazing Corporation
  • 30. WebSocket Client Support l  Java and JavaFX l  JavaScript l  Microsoft Silverlight and .NET l  Adobe Flex (Flash) 30 JavaOne 2011 © 2011 – Kaazing Corporation
  • 31. WebSocket Emulation Emulation for browsers with no native WebSocket support: l  Kaazing WebSocket Gateway: makes WebSocket work in all browsers today: l  Internet Explorer 6, 7, 8 l  Firefox 3.6 l  And more . . . 31 JavaOne 2011 © 2011 – Kaazing Corporation
  • 32. Kaazing JMS Edition l  Messages traverse firewalls and proxies l  Fast, secure communication over the Internet l  Message distribution to massive numbers of clients thanks to resource offloading (fan-out) 32 JavaOne 2011 © 2011 – Kaazing Corporation
  • 33. Resource Offloading ●  Connection + Session offload (fan out) l  Reduces broker resource usage l  Minimal connections, sessions to broker ●  Java NIO (Apache Mina framework) ●  Subscription offload l  Multiplexed over shared connection, single message consumer l  Gateway tracks subscribed topics and queues from all connected clients l  Gateway handles individual client acknowledgments 33 JavaOne 2011 © 2011 – Kaazing Corporation
  • 34. Resource Offloading 34 JavaOne 2011 © 2011 – Kaazing Corporation
  • 35. JMS Gateway Features ●  “stomp.jms” service l  Clients speak STOMP to the service. l  Service uses vendor's JMS API to talk to broker l  Connection, session and subscription offload ●  “stomp.proxy” service l  Clients speak STOMP to the service l  Service uses STOMP to talk to “stomp.jms” service running on another Gateway l  Further offload ●  Gateway clusters for High Availability 35 JavaOne 2011 © 2011 – Kaazing Corporation
  • 36. Using Multiple Gateways ●  Hundreds of thousands of clients or more can be supported by using a network of gateways ●  “stomp.proxy” gateways at the edge (near users) l  Route messages to central gateway running “stomp.jms” service l  Connection offloading (single connection to central gateway) ●  Most network traffic is local ●  Use gateway clusters for HA 36 JavaOne 2011 © 2011 – Kaazing Corporation
  • 37. Using Multiple Gateways 37 JavaOne 2011 © 2011 – Kaazing Corporation
  • 38. Writing Applications l  JMS API is available to code running within the browser or mobile device l  Gateway provides client libraries l  Written like a Java JMS client l  Similar concepts and APIs for each client technology (JavaScript, Flash, .Net) l  Application needs to include Kaazing JMS library files (jars, .js) 38 JavaOne 2011 © 2011 – Kaazing Corporation
  • 39. Live Customer Application 39 JavaOne 2011 © 2011 – Kaazing Corporation
  • 40. Take-aways l  HTML5 WebSockets offers a paradigm shift for highly interactive and scalable Web applications l  High level protocols can be extended beyond the firewall all the way to Web devices: l  JMS l  XMPP l  AMQP l  Production solution with live customers available today 40 JavaOne 2011 © 2011 – Kaazing Corporation
  • 41. Conclusion “We’re committed to providing real-time access to critical management information across the enterprise... Kaazing solves the industry’s fundamental issues which have kept yesterday’s web architecture from meeting these needs.” Quintin Gomez, CTO of ITRS Group, 28 Sep 11 41 JavaOne 2011 © 2011 – Kaazing Corporation
  • 42. Questions and Answers 42 JavaOne 2011 © 2011 – Kaazing Corporation