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.

WebSockets and Java

3,036 views

Published on

A short presentation on WebSockets and their Java server-side usage.

Published in: Technology, Education
  • Best dissertation help you can get, thank god a friend suggested me ⇒⇒⇒WRITE-MY-PAPER.net ⇐⇐⇐ otherwise I could have never completed my dissertation on time.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

WebSockets and Java

  1. 1. WebSocket Bozhidar Bozhanov ...one day at home I decided I'm bored => a WebSocket-based game for http://computoser.com
  2. 2. Usecases ● Games ● Stock-exchange application ● ...anything, really
  3. 3. Why WebSocket? ● Push ● Real-time communication ● Resource-light ● Intuitive, non-hacky
  4. 4. Up to now ● Ajax polling (a.k.a. "are we there yet?") ● Long-polling, streaming ● Plugins – flash/applets/ActiveX ● Problems: hacky, resource-heavy, serverthread-unfriendly
  5. 5. WebSocket ● Standard (HTML5) ● TCP, full-duplex ● More effective on the server-side ● High-level protocols ontop – STOMP, WAMP, etc.
  6. 6. Client-side ● Standard JavaScript API ● Browser support – problematic ● SockJS, socket.io, fallbacks
  7. 7. Server-side ● node.js ● Java – Java EE WebSocket API (JSR-356) ● ● Servlet container implementations – thread pools Spring-MVC API, Spring Messaging API
  8. 8. Java WebSocket API vs Spring ● ● Very similar One handler per endpoint, differentiate based on payload ● Out-of-the-box dependency injection with spring ● No annotation configuration in spring (yet)
  9. 9. Messaging ● ● Alternative architecture Using a message broker (simple/ActiveMQ/RabbitMQ/..) behind spring ● STOMP over WebSocket ● Client subscribes for events
  10. 10. DDD and TDD ● DDD comes naturally ● Objects and their workflows are easily testable ● Very few mocks, comparable to spring-mvc @RequestMappings
  11. 11. Security and authentication ● WSS vs WS (ws://example.com/game) ● No same-origin policy. Origin header. ● Validate input and output ● Authentication – cookies? Cookie-like workflow.
  12. 12. Conclusion ● It's cool :)

×