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.

Hornet q and-the-web-jud-con-2010

674 views

Published on

  • Be the first to comment

  • Be the first to like this

Hornet q and-the-web-jud-con-2010

  1. 1. HornetQ & The WebHow HornetQ Embraces the Web and Its Different Forms Jeff Mesnil
  2. 2. Who?
  3. 3. Who?• Jeff Mesnil• Software Developer• Red Hat, JBoss• jmesnil@{redhat|gmail}.com• http://jmesnil.net/• twitter: @jmesnil
  4. 4. What?
  5. 5. What?• What is HornetQ?
  6. 6. What?• What is HornetQ?• HornetQ & The Web
  7. 7. What?• What is HornetQ?• HornetQ & The Web• HornetQ & REST
  8. 8. What?• What is HornetQ?• HornetQ & The Web• HornetQ & REST• HornetQ & HTML5 WebSocket
  9. 9. What?• What is HornetQ?• HornetQ & The Web• HornetQ & REST• HornetQ & HTML5 WebSocket• Pros & Cons
  10. 10. What?• What is HornetQ?• HornetQ & The Web• HornetQ & REST• HornetQ & HTML5 WebSocket• Pros & Cons• Questions?
  11. 11. • http://jboss.org/hornetq/
  12. 12. • http://jboss.org/hornetq/• JBoss community project
  13. 13. • http://jboss.org/hornetq/• JBoss community project• Open Source (Apache License 2.0)
  14. 14. • http://jboss.org/hornetq/• JBoss community project• Open Source (Apache License 2.0)• Multi-protocol asynchronous messaging system
  15. 15. • http://jboss.org/hornetq/• JBoss community project• Open Source (Apache License 2.0)• Multi-protocol asynchronous messaging system• Performance
  16. 16. • http://jboss.org/hornetq/• JBoss community project• Open Source (Apache License 2.0)• Multi-protocol asynchronous messaging system• Performance• Usability
  17. 17. Usability
  18. 18. Usability• Ease of use (configuration, deployment)
  19. 19. Usability• Ease of use (configuration, deployment)• Simple API
  20. 20. Usability• Ease of use (configuration, deployment)• Simple API• Documentation
  21. 21. Usability• Ease of use (configuration, deployment)• Simple API• Documentation• 90+ examples
  22. 22. Usability• Ease of use (configuration, deployment)• Simple API• Documentation• 90+ examples • A feature without documentation and example is useless
  23. 23. Usability• Ease of use (configuration, deployment)• Simple API• Documentation• 90+ examples • A feature without documentation and example is useless• Minimal third-party dependencies
  24. 24. Deployment
  25. 25. Deployment• Fully functional standalone messaging server
  26. 26. Deployment• Fully functional standalone messaging server• Default messaging provider for JBoss AS 6
  27. 27. Deployment• Fully functional standalone messaging server• Default messaging provider for JBoss AS 6• Integrated with any Java EE application server using its JCA adaptor
  28. 28. Deployment• Fully functional standalone messaging server• Default messaging provider for JBoss AS 6• Integrated with any Java EE application server using its JCA adaptor• Use dependency-injection framework to embed it in your application
  29. 29. Generic Messaging Architecture
  30. 30. Generic Messaging Architecture• Simple set of POJOs (JMS-agnostic)
  31. 31. Generic Messaging Architecture• Simple set of POJOs (JMS-agnostic)• No hard dependencies on JMS, JNDI, JCA
  32. 32. Generic Messaging Architecture• Simple set of POJOs (JMS-agnostic)• No hard dependencies on JMS, JNDI, JCA• JMS is 1 way to use HornetQ
  33. 33. Generic Messaging Architecture• Simple set of POJOs (JMS-agnostic)• No hard dependencies on JMS, JNDI, JCA• JMS is 1 way to use HornetQ• 2 ways to use HornetQ on the Web
  34. 34. Generic Messaging Architecture• Simple set of POJOs (JMS-agnostic)• No hard dependencies on JMS, JNDI, JCA• JMS is 1 way to use HornetQ• 2 ways to use HornetQ on the Web• Different messaging APIs / protocols in a single consistent messaging system
  35. 35. Performance
  36. 36. Performance• Very high performance journal
  37. 37. Performance• Very high performance journal • No relational database
  38. 38. Performance• Very high performance journal • No relational database • Java NIO
  39. 39. Performance• Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO
  40. 40. Performance• Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO• Very fast transport layer
  41. 41. Performance• Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO• Very fast transport layer • Netty
  42. 42. Performance• Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO• Very fast transport layer • Netty• Don’t take my word for it!
  43. 43. Performance• Very high performance journal • No relational database • Java NIO • JNI interface to Linux asynchronous IO• Very fast transport layer • Netty• Don’t take my word for it! • http://www.spec.org/jms2007/results/jms2007.html
  44. 44. Supported Protocols
  45. 45. Supported Protocols• Core• JMS• STOMP• REST
  46. 46. HornetQ Core Protocol
  47. 47. HornetQ Core Protocol• Java
  48. 48. HornetQ Core Protocol• Java• Optimized
  49. 49. HornetQ Core Protocol• Java• Optimized• Send messages to an address
  50. 50. HornetQ Core Protocol• Java• Optimized• Send messages to an address• Consume messages from a queue
  51. 51. HornetQ Core Protocol• Java• Optimized• Send messages to an address• Consume messages from a queue• Bindings between addresses and queues and queues and consumers define the messaging model
  52. 52. HornetQ Core
  53. 53. HornetQ Core
  54. 54. HornetQ Core Address
  55. 55. HornetQ CoreProducer Address
  56. 56. HornetQ Core messageProducer Address sends
  57. 57. HornetQ Core messageProducer Address sends Consumer
  58. 58. HornetQ Core messageProducer Address sends Queue Consumer
  59. 59. HornetQ Core messageProducer Address sends Queue Consumer
  60. 60. HornetQ Core messageProducer Address sends message Queue Consumer
  61. 61. HornetQ Core messageProducer Address sends ? message Queue Consumer
  62. 62. JMS API
  63. 63. JMS API• Java / Java EE
  64. 64. JMS API• Java / Java EE• Point-to-Point (queues) • 1 producer - 1 consumer
  65. 65. JMS API• Java / Java EE• Point-to-Point (queues) • 1 producer - 1 consumer• Publish/Subscribe (topics) • 1 producer - N consumers
  66. 66. JMS Queue
  67. 67. JMS QueueAddress
  68. 68. JMS QueueAddress Queue
  69. 69. JMS QueueAddress Queue
  70. 70. JMS QueueAddress Queue Consumer 1 Consumer 2
  71. 71. JMS QueueAddress Queue Consumer 1 Consumer 2
  72. 72. JMS QueueProducer Address Queue Consumer 1 Consumer 2
  73. 73. JMS Queue messageProducer Address sends Queue Consumer 1 Consumer 2
  74. 74. JMS Queue messageProducer Address sends message Queue Consumer 1 Consumer 2
  75. 75. JMS Queue messageProducer Address sends Queue Consumer 1 Consumer 2
  76. 76. JMS Queue messageProducer Address sends Queue Consumer 1 Consumer 2 message
  77. 77. JMS Topic
  78. 78. JMS TopicProducer
  79. 79. JMS TopicProducer Consumer 1 Consumer 2
  80. 80. JMS TopicProducer Address Consumer 1 Consumer 2
  81. 81. JMS TopicProducer Address Queue Consumer 1 Consumer 2
  82. 82. JMS TopicProducer Address Queue Consumer 1 Queue Consumer 2
  83. 83. JMS TopicProducer Address Queue Consumer 1 Queue Consumer 2
  84. 84. JMS Topic messageProducer Address sends Queue Consumer 1 Queue Consumer 2
  85. 85. JMS Topic messageProducer Address sends Queue Consumer 1 Queue Consumer 2
  86. 86. JMS Topic messageProducer Address sends message Queue Consumer 1 Queue Consumer 2 message
  87. 87. JMS Models
  88. 88. JMS Models• JMS Queue • 1 address - 1 queue binding • Many consumers for the queue
  89. 89. JMS Models• JMS Queue • 1 address - 1 queue binding • Many consumers for the queue• JMS Topic • 1 address - many queues binding • 1 single consumer per queue
  90. 90. STOMP
  91. 91. STOMP• http://stomp.codehaus.org/
  92. 92. STOMP• http://stomp.codehaus.org/• Text-orientated messaging protocol
  93. 93. STOMP• http://stomp.codehaus.org/• Text-orientated messaging protocol• Interoperability
  94. 94. STOMP• http://stomp.codehaus.org/• Text-orientated messaging protocol• Interoperability• Clients for many languages
  95. 95. STOMP• http://stomp.codehaus.org/• Text-orientated messaging protocol• Interoperability• Clients for many languages• Simple and flexible (headers, ack, transactions)
  96. 96. STOMP$ telnet localhost 61613CONNECTlogin: jmesnilpasscode: mypassword^@SENDdestination:/queue/myqueuethis is my message body^@
  97. 97. REST
  98. 98. REST• HTTP-Based RESTful API• More on that in a minute...
  99. 99. Many Other Features
  100. 100. Many Other Features• Clustering, HA, Failover• Bridges and Diverts• Management (JMX, JMS)• Dead Letters, Expiration• ...• http://community.jboss.org/wiki/HornetQFeatures
  101. 101. But
  102. 102. ButHornetQ & The Web
  103. 103. HornetQ & The Web
  104. 104. HornetQ & The Web• Web is everywhere
  105. 105. HornetQ & The Web• Web is everywhere• Cloud Computing
  106. 106. HornetQ & The Web• Web is everywhere• Cloud Computing• Integration • Entreprise environment • Heterogenous platforms
  107. 107. HornetQ & The Web• Web is everywhere• Cloud Computing• Integration • Entreprise environment • Heterogenous platforms• End-user applications • Web Browsers • RIA
  108. 108. HornetQ & The Web• Web is everywhere• Cloud Computing• Integration • Entreprise environment • Heterogenous platforms• End-user applications • Web Browsers • RIA• More and more web-based applications needs messaging
  109. 109. Messaging and the Web
  110. 110. Messaging and the Web• Asynchronous• Loosely-coupled• Distributed
  111. 111. HornetQ and the Web
  112. 112. HornetQ and the Web• HornetQ Core/JMS over HTTP
  113. 113. HornetQ and the Web• HornetQ Core/JMS over HTTP• REST API over HTTP
  114. 114. HornetQ and the Web• HornetQ Core/JMS over HTTP• REST API over HTTP• STOMP over HTML5 WebSocket
  115. 115. HornetQ Over HTTP
  116. 116. HornetQ Over HTTP• Use HTTP instead of TCP as the transport layer• Work around firewalls• Not Web-friendly • Requires HornetQ Java client library • HornetQ Core wireformat encoded
  117. 117. HornetQ REST API
  118. 118. HornetQ REST API• RESTful API to do messaging over HTTP
  119. 119. HornetQ REST API• RESTful API to do messaging over HTTP• http://en.wikipedia.org/wiki/Representational_State_Transfer
  120. 120. HornetQ REST API• RESTful API to do messaging over HTTP• http://en.wikipedia.org/wiki/Representational_State_Transfer• Based on RESTEasy
  121. 121. RESTEasy
  122. 122. RESTEasy• http://www.jboss.org/resteasy/• JBoss community project• Open Source (Apache license 2.0)• Fully certified JAX-RS implementation• Portable to any application server/web container• Rich set of providers (XML, JSON, YAML, Atom, etc.)• JAXB marshalling into XML, JSON, etc.• Wrappers for maps, arrays, lists, and sets of JAXB Objects.• GZIP content-encoding• Rich interceptor model• EJB, Seam, Guice, Spring, and Spring MVC integration
  123. 123. TomTom Work [1/2]
  124. 124. TomTom Work [1/2]• http://www.tomtomwork.com/en/products/what.xml• Fleet management solution• Mobile navigation system connected to the web-based management and communication service• Two-way communication and navigation • Vehicles send their position and other infos • Receive incoming text messages from TomTom servers
  125. 125. TomTom Work [2/2]
  126. 126. TomTom Work [2/2]• GPS devices in the vehicles (GPRS / TCP)• TomTom data center • JMS • DB • GUI + REST Web Services• 120K+ devices• 150K JMS messages/min at peak time (2 peaks every day)• 120M JMS messages/day
  127. 127. Demo
  128. 128. Demo• Application to track the location of users
  129. 129. Demo• Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API)
  130. 130. Demo• Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API) • Web application to monitor the users’ positions (STOMP over HTML5 WebSocket)
  131. 131. Demo• Application to track the location of users • Users will use their mobile phones to broadcast their position (REST API) • Web application to monitor the users’ positions (STOMP over HTML5 WebSocket) • Application to keep a log of everybody’s moves (JMS)
  132. 132. JMS Topic JMS Monitoring Application
  133. 133. HornetQ Server Configurationhornetq-jms.xml<configuration> <topic name="trackers"> <entry name="/topic/trackers" /> </topic></configuration>hornetq-configuration.xml<acceptor name="jms"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class></acceptor><acceptor name="websockets"> <factory-class>org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory</factory-class> <param key="protocol" value="stomp_ws" /> <param key="port" value="61614" /></acceptor>
  134. 134. RESTEasy ConfigurationWEB-INF/web.xml<listener> <listener-class>org.jboss.resteasy.plugins.server.servlet.ResteasyBootstrap</listener-class></listener><listener> <listener-class>org.hornetq.rest.integration.HornetqBootstrapListener</listener-class></listener><listener> <listener-class>org.hornetq.rest.integration.RestMessagingBootstrapListener</listener-class></listener>...<context-param> <param-name>rest.messaging.config.file</param-name> <param-value>rest-config.xml</param-value></context-param>
  135. 135. RESTEasy Configurationrest-config.xml<rest-messaging> <server-in-vm-id>0</server-in-vm-id> <use-link-headers>false</use-link-headers> <default-durable-send>false</default-durable-send> <dups-ok>true</dups-ok> <topic-push-store-dir>topic-push-store</topic-push-store-dir> <queue-push-store-dir>queue-push-store</queue-push-store-dir> <producer-session-pool-size>10</producer-session-pool-size> <session-timeout-task-interval>1</session-timeout-task-interval> <consumer-session-timeout-seconds>300</consumer-session-timeout-seconds> <consumer-window-size>-1</consumer-window-size></rest-messaging>
  136. 136. Demo
  137. 137. HornetQ REST API
  138. 138. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html
  139. 139. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ
  140. 140. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ• Usable by any programming language that has an HTTP client library
  141. 141. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ• Usable by any programming language that has an HTTP client library• Zero client footprint (no libraries to download, install and deploy)
  142. 142. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ• Usable by any programming language that has an HTTP client library• Zero client footprint (no libraries to download, install and deploy)• No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message
  143. 143. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ• Usable by any programming language that has an HTTP client library• Zero client footprint (no libraries to download, install and deploy)• No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message• Ligthweight interoperability
  144. 144. HornetQ REST API• RESTful messaging specification • http://www.jboss.org/reststar/specifications/messaging.html• Simple REST/HTTP interface to access HornetQ• Usable by any programming language that has an HTTP client library• Zero client footprint (no libraries to download, install and deploy)• No envelope (à la SOAP) or feed (à la Atom) format requirements • the HTTP request/response is the message• Ligthweight interoperability• Pub/Sub (topics) and Point-to-point (queues)
  145. 145. HornetQ REST API
  146. 146. HornetQ REST API• Follow the headers
  147. 147. HornetQ REST API• Follow the headers• Duplicate Detection
  148. 148. HornetQ REST API• Follow the headers• Duplicate Detection• Persistent messages ?durable=true
  149. 149. Send a Message [1/2]=> Query the resource URLHEAD /topics/jms.topic.trackers HTTP/1.1Host: example.com--- Response ---HTTP/1.1 200 Okmsg-create: http://example.com/topics/jms.topic.trackers/createmsg-create-with-id: http://example.com/topics/jms.topic.trackers/create/{id}
  150. 150. Send a Message [2/2]POST /topics/jms.topic.trackers/createHost: example.comContent-Type: application/json{ "alias": "jmesnil", "position": { "coords": { "longitude": 65.735344446666666, "latitude": 35.198200083333326 }, "timestamp": 1285943662645 }}--- Response ---HTTP/1.1 201 Createdmsg-create-next: http://example.com/topics/jms.topic.trackers/create/002
  151. 151. Receive a Message - Pull [1/4]=> query the resource URLHEAD /topics/jms.topic.trackers HTTP/1.1Host: example.com--- Response ---HTTP/1.1 200 Okmsg-create: http://example.com/topics/jms.topic.trackers/createmsg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/pull-subscriptionsmsg-push-subscriptions: http://example.com/topics/jms.topic.trackers/push-subscriptions
  152. 152. Receive a Message - Pull [2/4]=> create a subscription by doing an empty POST on the msg-pull-subscriptions URLPOST /topics/jms.topic.trackers/pull-subscriptions HTTP/1.1Host: example.com--- Response ---HTTP/1.1 201 CreatedLocation: http://example.com/topics/jms.topic.trackers/pull-subscriptions/auto-ack/222msg-consume-next: http://example.com/topics/jms.topic.trackers/pull-subscriptions/auto-ack/222/consume-next-1
  153. 153. Receive a Message - Pull [3/4]=> consume the message by POSTing on the subscriptionPOST /topics/jms.topic.trackers/pull-subscriptions/auto-ack/222/consume-next-1Host: example.com--- Response ---HTTP/1.1 200 OkContent-Type: application/jsonmsg-consume-next: http://example.com/topics/jms.topic.trackers/pull-subscriptions/auto-ack/222/consume-next-2{ "alias": "jmesnil", "position": { "coords": { "longitude": 65.735344446666666, "latitude": 35.198200083333326, ... }, "timestamp": 1285943662645 }}
  154. 154. Receive a Message - Pull [4/4] => if there is no message to consume, will return 503POST /queues/jms.queue.bar/pull-consumers/consume-next-2Host: example.com--- Response ---Http/1.1 503 Service UnavailableRetry-After: 5msg-consume-next: http://example.com/queues/jms.queue.bar/pull-consumers/333/consume-next-2
  155. 155. Receive a Message - Push[1/2]=> query the Topic resource URLHEAD /topics/jms.topic.trackers HTTP/1.1Host: example.com--- Response ---HTTP/1.1 200 Okmsg-create: http://example.com/topics/jms.topic.trackers/createmsg-pull-subscriptions: http://example.com/topics/jms.topic.trackers/pull-subscriptionsmsg-push-subscriptions: http://example.com/topics/jms.topic.trackers/push-subscriptions
  156. 156. Receive a Message - Push[2/2]=> create a push subscriptionPOST /topics/jms.topic.trackers/push-subscriptionsHost: example.comContent-Type: application/xml<push-topic-registration> <link rel="template" href="http://somewhere.com/resources/{id}/messages" method="POST"/></push-topic registration>--- Response ---HTTP/1.1 201 CreatedLocation: http://example.com/topics/jms.topic.trackers/push-subscriptions/1-333-1212=> new messages will be POSTed to http://somewhere.com/resources/{id}/messages URL
  157. 157. Create a DestinationPOST /topicsHost: example.comContent-Type: application/hornetq.jms.topic+xml<topic name="testTopic" />--- Response ---HTTP/1.1 201 CreatedLocation: http://example.com/topics/jms.topic.testTopic
  158. 158. HTML5
  159. 159. HTML5• http://www.w3.org/TR/html5/
  160. 160. HTML5• http://www.w3.org/TR/html5/• Revision of HTML markup language
  161. 161. HTML5• http://www.w3.org/TR/html5/• Revision of HTML markup language• JavaScript APIs
  162. 162. HTML5• http://www.w3.org/TR/html5/• Revision of HTML markup language• JavaScript APIs • canvas, geolocation, video, audio, etc.
  163. 163. HTML5• http://www.w3.org/TR/html5/• Revision of HTML markup language• JavaScript APIs • canvas, geolocation, video, audio, etc. • WebSocket!
  164. 164. HTML5 WebSocket
  165. 165. HTML5 WebSocket• «TCP for the Web»...
  166. 166. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server
  167. 167. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server• same-origin security model
  168. 168. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server• same-origin security model• JavaScript API in the browser
  169. 169. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server• same-origin security model• JavaScript API in the browser • http://dev.w3.org/html5/websockets/
  170. 170. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server• same-origin security model• JavaScript API in the browser • http://dev.w3.org/html5/websockets/• WebSocket protocol on the server
  171. 171. HTML5 WebSocket• «TCP for the Web»...• bidirectional communication between the browser and the web server• same-origin security model• JavaScript API in the browser • http://dev.w3.org/html5/websockets/• WebSocket protocol on the server • http://tools.ietf.org/html/draft-hixie- thewebsocketprotocol-76
  172. 172. STOMP Over WebSocket
  173. 173. STOMP Over WebSocket• WebSocket instead of TCP
  174. 174. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol
  175. 175. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol• JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple
  176. 176. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol• JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple• ActiveMQ, RabbitMQ(?)
  177. 177. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol• JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple• ActiveMQ, RabbitMQ(?)• Talks about adding it to STOMP 2.0 specification
  178. 178. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol• JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple• ActiveMQ, RabbitMQ(?)• Talks about adding it to STOMP 2.0 specification• Work with text only (no bytes)
  179. 179. STOMP Over WebSocket• WebSocket instead of TCP• STOMP as the messaging protocol• JavaScript libraries to send and receive STOMP messages • http://jmesnil.net/stomp-websocket/doc/ • http://github.com/krukow/stomple• ActiveMQ, RabbitMQ(?)• Talks about adding it to STOMP 2.0 specification• Work with text only (no bytes)• Receive message by push-only
  180. 180. Demo
  181. 181. STOMP Over WebSocket
  182. 182. STOMP Over WebSocket• JavaScript-based
  183. 183. STOMP Over WebSocket• JavaScript-based• Looks like other STOMP clients
  184. 184. STOMP Over WebSocket• JavaScript-based• Looks like other STOMP clients• Send and receive text-only messages
  185. 185. Create a Client// create a clientvar url = "ws://example.com:61614/stomp";var client = Stomp.client(url);// connect to the STOMP serverclient.connect(login, passcode, function() { // called back after the client is connected // and authenticated to the server});...// disconnect from the serverclient.disconnect();
  186. 186. Send and Receive Messages// send a messagevar tracker = ...; // retrieved from Geolocation APIclient.send("jms.topic.trackers", {}, JSON.stringify(tracker));// subscribe to a destinationvar sub_id = client.subscribe("jms.topic.trackers", function(message){ // called back everytime a message is sent to the destination var tracker = JSON.parse(message.body); ...});// unsubscribe from a destinationclient.unsubscribe(sub_id);
  187. 187. REST or WebSocket?
  188. 188. REST or WebSocket?• Different usage and timeline
  189. 189. REST or WebSocket?• Different usage and timeline• WebSocket
  190. 190. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like
  191. 191. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like • (+) push data from the server to the browser
  192. 192. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand
  193. 193. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand• REST
  194. 194. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand• REST • (+) Works everywhere now
  195. 195. REST or WebSocket?• Different usage and timeline• WebSocket • (+) TCP-like • (+) push data from the server to the browser • (-) Limited support now, will likely expand• REST • (+) Works everywhere now • (-) No push messages in the browser
  196. 196. Conclusion
  197. 197. Conclusion• Different ways to do messaging on the Web
  198. 198. Conclusion• Different ways to do messaging on the Web• Integrate with the whole Java / Java EE ecosystem
  199. 199. Conclusion• Different ways to do messaging on the Web• Integrate with the whole Java / Java EE ecosystem• Embraces Web principles (REST)
  200. 200. Conclusion• Different ways to do messaging on the Web• Integrate with the whole Java / Java EE ecosystem• Embraces Web principles (REST)• Integration & interoperability
  201. 201. Conclusion• Different ways to do messaging on the Web• Integrate with the whole Java / Java EE ecosystem• Embraces Web principles (REST)• Integration & interoperability• ... Performance(?)
  202. 202. Demo Source• http://github.com/jmesnil/hornetq/tree/judcon
  203. 203. Questions?
  204. 204. Danke Schön!

×