Reactive applications with Spring , AngularDart and Websocket
This talk is a feedback about developing reactive applications with Spring on server-side and Dart on client-side, based on OpenSnap, a HTML5 clone of SnapChat.
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Reactive applications with Spring AngularDart and Websocket Sébastien Deleuze, Spring Framework Commiter and Dart GDE, Pivotal @sdeleuze
support § WebSocket, SockJS and STOMP § AsyncRestTemplate § Generic types used as qualifier § « Bill Of Materials » Maven § @RestController § Groovy Bean Definition DSL
(proxy, IE) § Spring Framework 4 supports SockJS protocol § Client side: thin layer on Websocket API with several possible transports (Websocket, http polling, iframe …) § Server side: a simple option to activate § Must have for every large audience website
low level for application development § Stomp over Websocket/SockJS § SocketIO simplicity + the power of a real broker … § Client side: stomp.js or Dart Stomp client § Server side: methods annotated with @MessageMapping and @SubscribeMapping in you controller Server Client
and @SubscribeMapping /app/* /topic/* /queue/* Response to: /user/* a specific user /topic/* broadcast to subscribers /queue/* to the first one who retrieves the message Client Broker (embedded or external) Response Stomp message
• SimpleBroker: pure Java, included out of the box • External broker: RabbitMQ, Appolo … ! § Why should I use an external broker? • Broadcast in cluster mode • Monitoring • Performance tuning • Interoperability • Message persistence
with Spring Security • Session cookie transmitted during Websocket handshake • No Stomp credential support yet § Authorizations • Possible by implementing a custom ChannelInterceptor (cf. OpenSnap) • Inluded in future Spring Framework and Spring Security releases app: '*': 'USER' user: queue: '*': 'USER' 'error': 'ANONYMOUS' queue: 'snap-‐created': 'ADMIN' topic: 'user-‐authenticated': 'USER' 'snap-‐created': 'USER,ADMIN' stomp-‐security.yml
Point { final num _x, _y; num get x => _x; num get y => _y; Point(this._x, this._y); num distanceTo(Point other) { var dx = _x -‐ other.x; var dy = _y -‐ other.y; return sqrt(dx * dx + dy * dy); } } main() { var a = new Point(2, 3); var b = new Point(3, 4); print('distance from a to b = ${a.distanceTo(b)}'); }
port § Maybe the best Angular version currently available § Quite young, but progress very quickly § Awesome to use § Reusable Bootstrap components with AngularDart UI
Cluster mode § Dart • Chrome native support • Firefox, IE and Safari support § Spring • Websocket scope • @SentToUser support in cluster mode • Resource Handling
Inc. and licensed under a Creative Commons Attribution-NonCommercial license: http://creativecommons.org/licenses/by-nc/3.0/ Thanks! Demo : http://opensnap.io Code : https://github.com/sdeleuze/opensnap ! Spring : @springcentral Dart : http://g.co/dartisans ! Follow me on @sdeleuze …