NullMQ @ PDX

10,011 views

Published on

Published in: Technology, Education

NullMQ @ PDX

  1. 1. NullMQ ZEROMQ SEMANTICS IN THE BROWSERJeff Lindsay Bulat Shakirzyanov@progrium @avalanche123
  2. 2. libzmq
  3. 3. High-level patterns libzmq
  4. 4. PhilosophyHigh-level patterns libzmq
  5. 5. PhilosophyHigh-level patterns libzmq
  6. 6. PhilosophyHigh-level patterns API / Semantics libzmq
  7. 7. Toolkit for building messaging systems...
  8. 8. Toolkit for building messaging systems... ...behind your firewall
  9. 9. Toolkit for building messaging systems... ...behind your firewall ...not for customers
  10. 10. Toolkit for building messaging systems... ...behind your firewall ...not for customers ...certainly not with the browser
  11. 11. WITH VOICE MAKE & RECEIVE PHONE CALLS SEND & RECEIVE TEXT MESSAGES INSTANTLY BUY PHONE NUMBERS ADD VOICE TO WEB & MOBILE APPS
  12. 12. Browser Browser
  13. 13. ZeroMQ in the browser?
  14. 14. ZeroMQ in the browser? • libzmq is a C++ library
  15. 15. ZeroMQ in the browser? • libzmq is a C++ library • Browser extension not viable
  16. 16. ZeroMQ in the browser? • libzmq is a C++ library • Browser extension not viable • ZMTP is not valuable by itself
  17. 17. Let’s say we did...
  18. 18. Let’s say we did... • Security?
  19. 19. Let’s say we did... • Security? • Skip existing auth infrastructure
  20. 20. Let’s say we did... • Security? • Skip existing auth infrastructure • Need to make something up
  21. 21. Let’s say we did... • Security? • Skip existing auth infrastructure • Need to make something up • Direct connections?
  22. 22. Let’s say we did... • Security? • Skip existing auth infrastructure • Need to make something up • Direct connections? • Lots of open connections, open ports
  23. 23. Let’s say we did... • Security? • Skip existing auth infrastructure • Need to make something up • Direct connections? • Lots of open connections, open ports • Just not “web friendly”
  24. 24. PhilosophyHigh-level patterns API / Semantics libzmq
  25. 25. PhilosophyHigh-level patterns API / Semantics libzmq
  26. 26. What do we want?
  27. 27. What do we want?• Near feature/semantic parity with ZeroMQ
  28. 28. What do we want?• Near feature/semantic parity with ZeroMQ• Throughput performance not as important
  29. 29. What do we want?• Near feature/semantic parity with ZeroMQ• Throughput performance not as important• Embrace nature of the web in design
  30. 30. What do we want?• Near feature/semantic parity with ZeroMQ• Throughput performance not as important• Embrace nature of the web in design• Single connection, service multiplexing
  31. 31. What do we want?• Near feature/semantic parity with ZeroMQ• Throughput performance not as important• Embrace nature of the web in design• Single connection, service multiplexing• Use existing transports, protocols, etc
  32. 32. NullMQ What do we want?• Near feature/semantic parity with ZeroMQ• Throughput performance not as important• Embrace nature of the web in design• Single connection, service multiplexing• Use existing transports, protocols, etc
  33. 33. What do we have?
  34. 34. WebSocket
  35. 35. WebSocket• ZMTP over WebSocket?
  36. 36. WebSocket• ZMTP over WebSocket? • Connection inefficient
  37. 37. WebSocket• ZMTP over WebSocket? • Connection inefficient • Not extensible
  38. 38. WebSocket• ZMTP over WebSocket? • Connection inefficient • Not extensible • No easy parsers
  39. 39. WebSocket
  40. 40. WebSocket• STOMP over WebSocket?
  41. 41. WebSocket• STOMP over WebSocket? • Existing parsers, easy to write
  42. 42. WebSocket• STOMP over WebSocket? • Existing parsers, easy to write • Very much like HTTP
  43. 43. WebSocket• STOMP over WebSocket? • Existing parsers, easy to write • Very much like HTTP • Used primarily to multiplex
  44. 44. NullMQ
  45. 45. var url = "ws://hostname/gateway";var ctx = new nullmq.Context(url);socket = ctx.socket(nullmq.REP);socket.bind("nullmq://echo");socket.recvall(function(request) { socket.send("Got: "+request);});
  46. 46. var url = "ws://hostname/gateway";var ctx = new nullmq.Context(url);socket = ctx.socket(nullmq.REQ);socket.connect("nullmq://echo");socket.send("Hello world!");socket.recv(function(reply) { console.log(reply); // "Got: Hello world!"});
  47. 47. Browser ServerApplication Application NullMQ NullMQ STOMP STOMP WebSocket WebSocket
  48. 48. Browser Gateway BackendApplication Bridge ZMQ Socket NullMQ NullMQ ZMQ Socket STOMP STOMP ZMQ SocketWebSocket WebSocket
  49. 49. Presence Demo
  50. 50. NullMQ http://github.com/progrium/nullmqhttp://groups.google.com/group/nullmq @progrium @avalanche123
  51. 51. STOMP
  52. 52. STOMP• Simple and human-readable like HTTP
  53. 53. STOMP• Simple and human-readable like HTTP• Extensible via headers
  54. 54. STOMP• Simple and human-readable like HTTP• Extensible via headers• Library and server support
  55. 55. STOMP• Simple and human-readable like HTTP• Extensible via headers• Library and server support• An easy WebSocket subprotocol
  56. 56. STOMP• Simple and human-readable like HTTP• Extensible via headers• Library and server support• An easy WebSocket subprotocol• Can be used to model “virtual connections”
  57. 57. STOMP• Simple and human-readable like HTTP• Extensible via headers• Library and server support• An easy WebSocket subprotocol• Can be used to model “virtual connections”• Transactions for multipart messages
  58. 58. STOMP “Extensions”1. Frames include socket type header2. Header for “connect” or “bind” in SUBSCRIBE3. Req-Rep messages use “reply-to” header

×