lagom, reactive framework(paris jug2017)
TRANSCRIPT
![Page 1: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/1.jpg)
LagomReactive microservices framework
LagomReactive microservices framework
Fabrice Sznajderman - @fsznajderman14 mars 2017 @lagom
![Page 2: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/2.jpg)
Roadmap
● Microservices / Event Sourcing / CQRS
● Overview
● Principales fonctionnalités
● Live coding
● Next step
![Page 3: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/3.jpg)
Qui vous parle?
Fabrice Sznajderman
● Développeur Scala @Zenika○ Formateur Java/Scala
● Contributeur (Lagom, JHipster, rapture)
● Bagger (Scala - Lagom - SBT)
● Co-organisateur conférence ScalaIO
![Page 4: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/4.jpg)
Core concepts
Microservices / Event Sourcing / CQRS
![Page 5: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/5.jpg)
Microservices
![Page 6: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/6.jpg)
Microservices
![Page 7: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/7.jpg)
Microservices
Microservices-Based Architecture is a simple concept: it advocates creating a system from a collection of small, isolated services, each of which owns their data, and is independently isolated, scalable and resilient to failure. Services integrate with other services in order to form a cohesive system that’s far more flexible than the typical enterprise systems we build today.
Reactive Microservices Architecture: Design Principles for Distributed Systems - jonas Boner http://www.oreilly.com/programming/free/reactive-microservices-architecture.html
![Page 8: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/8.jpg)
Microservices
![Page 9: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/9.jpg)
Event Sourcing
![Page 10: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/10.jpg)
Approche traditionnelle
![Page 11: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/11.jpg)
Event sourcing
![Page 12: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/12.jpg)
CQRS
![Page 13: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/13.jpg)
CQRS
● Command● Query● Responsability● Segregation
![Page 14: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/14.jpg)
Approche traditionelle
![Page 15: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/15.jpg)
Write (Command) :Event log. Modèle simple.
Read (Query) : Dénormalisation, scalabillité, performance...
CQRS
![Page 16: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/16.jpg)
CQRS
![Page 17: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/17.jpg)
LagomOverview / Principales fonctionnalités / Live coding
![Page 18: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/18.jpg)
Overview
![Page 19: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/19.jpg)
● Construire un système de microservices
● Basé sur les principes réactifs
● Intégration dans l’environnement de développement
Overview - Objectifs
![Page 20: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/20.jpg)
● Coeur du framework est écrit en Scala
● API en Java 8
● API en Scala 2.11.*
Overview - Quel langage ?
![Page 21: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/21.jpg)
● Java 8 & Scala● (Immutables)● SBT / Maven● Jackson● Cassandra / JDBC*● Message broker* (Kafka)● Play framework● Akka : persistence, pub/Sub, cluster● Akka Stream
Overview - Composants techniques
*depuis la version 1.2.0
![Page 22: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/22.jpg)
Principales fonctionnalités
![Page 23: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/23.jpg)
● Description de l’API basée sur une interface
● Request / response synchrone
● Message asynchrone - Streaming
Fonctionnalités - Service API
![Page 24: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/24.jpg)
Fonctionnalités - Service API
public interface HelloWorldService extends Service {
ServiceCall<NotUsed, String> hi(String name);
@Override default Descriptor descriptor() { return named("helloWorld").withCalls(restCall(Method.GET, "/hello/:name", this::hi)); }}
![Page 25: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/25.jpg)
● Garde l’état courant en mémoire
● Capture et persiste tous les changements d’états (events)
● CQRS Read side (query & update)
● Clustering / sharding
● CassandraSession
Fonctionnalités - Persistance API
![Page 26: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/26.jpg)
Fonctionnalités - Persistance APIpublic class UserEntity extends PersistentEntity<UserCommand, UserEvent, UsersState> { @Override public Behavior initialBehavior(Optional<UsersState> snapshotState) { BehaviorBuilder b = newBehaviorBuilder( snapshotState.orElse(new UsersState(UsersList.builder().build(), "now")));
b.setCommandHandler( UserCommand.SignIn.class, (cmd, ctx) -> ctx.thenPersist(new UserSigned(cmd.name), evt -> ctx.reply(Done.getInstance())));
b.setEventHandler( UserSigned.class, evt -> { /*get information from event and update state*/ final UsersList newState = /*current update state*/; return new UsersState(newState, LocalDateTime.now().toString()); });
b.setReadOnlyCommandHandler(UserCommand.ListUsers.class, (cmd, ctx) -> ctx.reply(state().users.getUsers())); return b.build(); }}
![Page 27: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/27.jpg)
● ConductR pour la production
● Scalabilité
● Déploiement
● Monitoring
Fonctionnalités - Environnement Production
![Page 28: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/28.jpg)
● Consul / Zookeeper
● Treafik / HaProxy
● Docker
● Monitoring (traefik)
Fonctionnalités - Environnement Production (free)
![Page 29: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/29.jpg)
● Intégration dans l’IDE
● Plusieurs services fournis par défaut
● Rechargement du code à chaud
● Une seule commande pour démarrer le système
Fonctionnalités - Environnement de développement
![Page 30: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/30.jpg)
Structure d’un projet - Démarrage du système
● Une commande pour lancer le système : ○ sbt runAll / mvn runAll
● Plusieurs services activés au démarrage : ○ Cassandra
○ Service locator
○ Service gateway
○ Tous les services déclarés
![Page 31: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/31.jpg)
Structure d’un projet - Overview
![Page 32: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/32.jpg)
Live coding
![Page 33: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/33.jpg)
● Hello World
● Calculator - ConductR
● Sloak - CQRS / Events Sourcing
● Déploiement sans conductR - Etat des lieux
Roadmap - Live coding
![Page 34: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/34.jpg)
Next step
● [Documentation] http://www.lagomframework.com
● [Gitter] https://gitter.im/lagom/lagom
● [Github] https://github.com/lagom/lagom
● [Plugin] https://github.com/Fabszn/scaffolding-plugin-lagom
● [Communauté] https://github.com/Lagom-community
![Page 35: Lagom, reactive framework(paris jug2017)](https://reader034.vdocuments.site/reader034/viewer/2022042619/58e4d2611a28abf5048b4c43/html5/thumbnails/35.jpg)
Merci!