SlideShare une entreprise Scribd logo
Lagom
Reactive microservices framework
Lagom
Reactive microservices framework
Fabrice Sznajderman - @fsznajderman
14 mars 2017 @lagom
Roadmap
● Microservices / Event Sourcing / CQRS
● Overview
● Principales fonctionnalités
● Live coding
● Next step
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
Core concepts
Microservices / Event Sourcing / CQRS
Microservices
Microservices
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
Microservices
Event Sourcing
Approche traditionnelle
Event sourcing
CQRS
CQRS
● Command
● Query
● Responsability
● Segregation
Approche traditionelle
Write (Command) :
Event log. Modèle simple.
Read (Query) :
Dénormalisation, scalabillité, performance...
CQRS
CQRS
Lagom
Overview / Principales fonctionnalités / Live coding
Overview
● Construire un système de microservices
● Basé sur les principes réactifs
● Intégration dans l’environnement de développement
Overview - Objectifs
● Coeur du framework est écrit en Scala
● API en Java 8
● API en Scala 2.11.*
Overview - Quel langage ?
● 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
Principales fonctionnalités
● Description de l’API basée sur une interface
● Request / response synchrone
● Message asynchrone - Streaming
Fonctionnalités - Service API
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));
}
}
● 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
Fonctionnalités - Persistance API
public 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();
}
● ConductR pour la production
● Scalabilité
● Déploiement
● Monitoring
Fonctionnalités - Environnement Production
● Consul / Zookeeper
● Treafik / HaProxy
● Docker
● Monitoring (traefik)
Fonctionnalités - Environnement Production (free)
● 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
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
Structure d’un projet - Overview
Live coding
● Hello World
● Calculator - ConductR
● Sloak - CQRS / Events Sourcing
● Déploiement sans conductR - Etat des lieux
Roadmap - Live coding
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
Merci!

Contenu connexe

Tendances

[JSS2015] - Document db et nosql
[JSS2015] - Document db et nosql[JSS2015] - Document db et nosql
[JSS2015] - Document db et nosql
GUSS
 
[AFUP Lyon 2021] LDAP Tool Box Self Service Password
[AFUP Lyon 2021] LDAP Tool Box Self Service Password[AFUP Lyon 2021] LDAP Tool Box Self Service Password
[AFUP Lyon 2021] LDAP Tool Box Self Service Password
Worteks
 
Mongo db applicationmonitor
Mongo db applicationmonitorMongo db applicationmonitor
Mongo db applicationmonitorPhilippe Sfeir
 
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
DocDoku
 
[Campus du Libre 2020] Présentation de la solution W'Sweet
[Campus du Libre 2020] Présentation de la solution W'Sweet[Campus du Libre 2020] Présentation de la solution W'Sweet
[Campus du Libre 2020] Présentation de la solution W'Sweet
Worteks
 
Presentation cloud&drinks
Presentation cloud&drinksPresentation cloud&drinks
Presentation cloud&drinksIkoula
 
Les micro orm, alternatives à entity framework
Les micro orm, alternatives à entity frameworkLes micro orm, alternatives à entity framework
Les micro orm, alternatives à entity framework
MSDEVMTL
 
Beta 12c
Beta 12cBeta 12c
Beta 12c
Bobby Curtis
 
I don't always write reactive application but when I do, it run on raspberry pi
I don't always write reactive application but when I do, it run on raspberry piI don't always write reactive application but when I do, it run on raspberry pi
I don't always write reactive application but when I do, it run on raspberry pi
adelegue
 

Tendances (9)

[JSS2015] - Document db et nosql
[JSS2015] - Document db et nosql[JSS2015] - Document db et nosql
[JSS2015] - Document db et nosql
 
[AFUP Lyon 2021] LDAP Tool Box Self Service Password
[AFUP Lyon 2021] LDAP Tool Box Self Service Password[AFUP Lyon 2021] LDAP Tool Box Self Service Password
[AFUP Lyon 2021] LDAP Tool Box Self Service Password
 
Mongo db applicationmonitor
Mongo db applicationmonitorMongo db applicationmonitor
Mongo db applicationmonitor
 
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
Meetup Aperotech 4 : retour d'expérience Oracle Code One 2019
 
[Campus du Libre 2020] Présentation de la solution W'Sweet
[Campus du Libre 2020] Présentation de la solution W'Sweet[Campus du Libre 2020] Présentation de la solution W'Sweet
[Campus du Libre 2020] Présentation de la solution W'Sweet
 
Presentation cloud&drinks
Presentation cloud&drinksPresentation cloud&drinks
Presentation cloud&drinks
 
Les micro orm, alternatives à entity framework
Les micro orm, alternatives à entity frameworkLes micro orm, alternatives à entity framework
Les micro orm, alternatives à entity framework
 
Beta 12c
Beta 12cBeta 12c
Beta 12c
 
I don't always write reactive application but when I do, it run on raspberry pi
I don't always write reactive application but when I do, it run on raspberry piI don't always write reactive application but when I do, it run on raspberry pi
I don't always write reactive application but when I do, it run on raspberry pi
 

En vedette

МЭИ, крионика
МЭИ, крионика МЭИ, крионика
МЭИ, крионика
Valerija Pride (Udalova)
 
Apostila super
Apostila superApostila super
Apostila super
Saymo Wendel
 
Manual diseño de pisos industriales
Manual diseño de pisos industrialesManual diseño de pisos industriales
Manual diseño de pisos industriales
German Moreno Escobar
 
Cmasr 2 def
Cmasr 2 defCmasr 2 def
Cmasr 2 def
Caty Pérez
 
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
Toshihiko Yamakami
 
Agenda 7°5
Agenda 7°5Agenda 7°5
COMMISSION STAFF WORKING DOCUMENT
COMMISSION STAFF WORKING DOCUMENTCOMMISSION STAFF WORKING DOCUMENT
COMMISSION STAFF WORKING DOCUMENT
Do outro lado da barricada
 
Curso de Android Xamarin desde cero
Curso de Android Xamarin desde ceroCurso de Android Xamarin desde cero
Curso de Android Xamarin desde cero
Indevo
 
2 My First Day at School
2 My First Day at School2 My First Day at School
2 My First Day at School
Edwin Alvarado
 
Taking Dynamic Search Ads to the Next Level
Taking Dynamic Search Ads to the Next Level Taking Dynamic Search Ads to the Next Level
Taking Dynamic Search Ads to the Next Level
Michelle Morgan
 
родитељ едукатор2
родитељ едукатор2родитељ едукатор2
родитељ едукатор2
Tamara Ilić
 
Дружење са родитељима будућих првака
Дружење са родитељима будућих првакаДружење са родитељима будућих првака
Дружење са родитељима будућих првака
Tamara Ilić
 
Criterios de inclusión y exclusion
Criterios de inclusión y exclusionCriterios de inclusión y exclusion
Criterios de inclusión y exclusion
Danise Toro Da Ponte
 
Technology in the early years
Technology in the early yearsTechnology in the early years
Technology in the early years
Rebecca Davies
 
Bertha 6g 2
Bertha 6g 2Bertha 6g 2
Actividad
ActividadActividad
Actividad
Eva Gallardo
 
Actividad Eva
Actividad Eva Actividad Eva
Actividad Eva
Eva Gallardo
 
Startup Series #1: What To Do During Formation
Startup Series #1: What To Do During FormationStartup Series #1: What To Do During Formation
Startup Series #1: What To Do During Formation
Erin McClarty
 

En vedette (18)

МЭИ, крионика
МЭИ, крионика МЭИ, крионика
МЭИ, крионика
 
Apostila super
Apostila superApostila super
Apostila super
 
Manual diseño de pisos industriales
Manual diseño de pisos industrialesManual diseño de pisos industriales
Manual diseño de pisos industriales
 
Cmasr 2 def
Cmasr 2 defCmasr 2 def
Cmasr 2 def
 
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
イノベーション人材育成のためのオープン・ソース・ソフトウェア概説 (in Japanese)
 
Agenda 7°5
Agenda 7°5Agenda 7°5
Agenda 7°5
 
COMMISSION STAFF WORKING DOCUMENT
COMMISSION STAFF WORKING DOCUMENTCOMMISSION STAFF WORKING DOCUMENT
COMMISSION STAFF WORKING DOCUMENT
 
Curso de Android Xamarin desde cero
Curso de Android Xamarin desde ceroCurso de Android Xamarin desde cero
Curso de Android Xamarin desde cero
 
2 My First Day at School
2 My First Day at School2 My First Day at School
2 My First Day at School
 
Taking Dynamic Search Ads to the Next Level
Taking Dynamic Search Ads to the Next Level Taking Dynamic Search Ads to the Next Level
Taking Dynamic Search Ads to the Next Level
 
родитељ едукатор2
родитељ едукатор2родитељ едукатор2
родитељ едукатор2
 
Дружење са родитељима будућих првака
Дружење са родитељима будућих првакаДружење са родитељима будућих првака
Дружење са родитељима будућих првака
 
Criterios de inclusión y exclusion
Criterios de inclusión y exclusionCriterios de inclusión y exclusion
Criterios de inclusión y exclusion
 
Technology in the early years
Technology in the early yearsTechnology in the early years
Technology in the early years
 
Bertha 6g 2
Bertha 6g 2Bertha 6g 2
Bertha 6g 2
 
Actividad
ActividadActividad
Actividad
 
Actividad Eva
Actividad Eva Actividad Eva
Actividad Eva
 
Startup Series #1: What To Do During Formation
Startup Series #1: What To Do During FormationStartup Series #1: What To Do During Formation
Startup Series #1: What To Do During Formation
 

Similaire à Lagom, reactive framework(paris jug2017)

Lagom, reactive framework(chtijug2016)
Lagom, reactive framework(chtijug2016) Lagom, reactive framework(chtijug2016)
Lagom, reactive framework(chtijug2016)
Fabrice Sznajderman
 
Bbl microservices avec vert.x cdi elastic search
Bbl microservices avec vert.x cdi elastic searchBbl microservices avec vert.x cdi elastic search
Bbl microservices avec vert.x cdi elastic search
Idriss Neumann
 
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
Java entreprise edition et industrialisation du génie logiciel par m.youssfiJava entreprise edition et industrialisation du génie logiciel par m.youssfi
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
ENSET, Université Hassan II Casablanca
 
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Jean-Laurent de Morlhon
 
ParisJUG-2022-v0.4.pdf
ParisJUG-2022-v0.4.pdfParisJUG-2022-v0.4.pdf
ParisJUG-2022-v0.4.pdf
Jean-Francois James
 
Open source et microsoft azure reve ou realite ?
Open source et microsoft azure reve ou realite ?Open source et microsoft azure reve ou realite ?
Open source et microsoft azure reve ou realite ?
Christophe Villeneuve
 
Architecture microservices avec docker
Architecture microservices avec dockerArchitecture microservices avec docker
Architecture microservices avec docker
gcatt
 
Java dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de JonasJava dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de Jonas
Microsoft
 
Flex, une techno RIA incontournable pour les futures app web ?
Flex, une techno RIA incontournable pour les futures app web ?Flex, une techno RIA incontournable pour les futures app web ?
Flex, une techno RIA incontournable pour les futures app web ?
GreenIvory
 
Support de cours entrepise java beans ejb m.youssfi
Support de cours entrepise java beans ejb m.youssfiSupport de cours entrepise java beans ejb m.youssfi
Support de cours entrepise java beans ejb m.youssfi
ENSET, Université Hassan II Casablanca
 
Le Cloud IaaS & PaaS, OpenStack réseau et sécurité
Le Cloud IaaS & PaaS, OpenStack réseau et sécuritéLe Cloud IaaS & PaaS, OpenStack réseau et sécurité
Le Cloud IaaS & PaaS, OpenStack réseau et sécurité
Noureddine BOUYAHIAOUI
 
Architecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesArchitecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependances
ENSET, Université Hassan II Casablanca
 
Panel de solutions javascript
Panel de solutions javascriptPanel de solutions javascript
Panel de solutions javascript
jp_mouton
 
Javav formation-java-avance-hibernate-webservices
Javav formation-java-avance-hibernate-webservicesJavav formation-java-avance-hibernate-webservices
Javav formation-java-avance-hibernate-webservicesCERTyou Formation
 
Comment automatiser les commandes PowerShell pour optimiser la performance d'...
Comment automatiser les commandes PowerShell pour optimiser la performance d'...Comment automatiser les commandes PowerShell pour optimiser la performance d'...
Comment automatiser les commandes PowerShell pour optimiser la performance d'...
Microsoft Décideurs IT
 
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
Vincent Biret
 
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
Modern Workplace Conference Paris
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
Adyax
 
JSS2014 - StreamInsight
JSS2014 - StreamInsightJSS2014 - StreamInsight
JSS2014 - StreamInsight
GUSS
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
Abdelhakim Bachar
 

Similaire à Lagom, reactive framework(paris jug2017) (20)

Lagom, reactive framework(chtijug2016)
Lagom, reactive framework(chtijug2016) Lagom, reactive framework(chtijug2016)
Lagom, reactive framework(chtijug2016)
 
Bbl microservices avec vert.x cdi elastic search
Bbl microservices avec vert.x cdi elastic searchBbl microservices avec vert.x cdi elastic search
Bbl microservices avec vert.x cdi elastic search
 
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
Java entreprise edition et industrialisation du génie logiciel par m.youssfiJava entreprise edition et industrialisation du génie logiciel par m.youssfi
Java entreprise edition et industrialisation du génie logiciel par m.youssfi
 
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
Ou sont mes beans, contrats et workflows ? WOA et REST: Un changement de ment...
 
ParisJUG-2022-v0.4.pdf
ParisJUG-2022-v0.4.pdfParisJUG-2022-v0.4.pdf
ParisJUG-2022-v0.4.pdf
 
Open source et microsoft azure reve ou realite ?
Open source et microsoft azure reve ou realite ?Open source et microsoft azure reve ou realite ?
Open source et microsoft azure reve ou realite ?
 
Architecture microservices avec docker
Architecture microservices avec dockerArchitecture microservices avec docker
Architecture microservices avec docker
 
Java dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de JonasJava dans Windows Azure: l'exemple de Jonas
Java dans Windows Azure: l'exemple de Jonas
 
Flex, une techno RIA incontournable pour les futures app web ?
Flex, une techno RIA incontournable pour les futures app web ?Flex, une techno RIA incontournable pour les futures app web ?
Flex, une techno RIA incontournable pour les futures app web ?
 
Support de cours entrepise java beans ejb m.youssfi
Support de cours entrepise java beans ejb m.youssfiSupport de cours entrepise java beans ejb m.youssfi
Support de cours entrepise java beans ejb m.youssfi
 
Le Cloud IaaS & PaaS, OpenStack réseau et sécurité
Le Cloud IaaS & PaaS, OpenStack réseau et sécuritéLe Cloud IaaS & PaaS, OpenStack réseau et sécurité
Le Cloud IaaS & PaaS, OpenStack réseau et sécurité
 
Architecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependancesArchitecture jee principe de inversion de controle et injection des dependances
Architecture jee principe de inversion de controle et injection des dependances
 
Panel de solutions javascript
Panel de solutions javascriptPanel de solutions javascript
Panel de solutions javascript
 
Javav formation-java-avance-hibernate-webservices
Javav formation-java-avance-hibernate-webservicesJavav formation-java-avance-hibernate-webservices
Javav formation-java-avance-hibernate-webservices
 
Comment automatiser les commandes PowerShell pour optimiser la performance d'...
Comment automatiser les commandes PowerShell pour optimiser la performance d'...Comment automatiser les commandes PowerShell pour optimiser la performance d'...
Comment automatiser les commandes PowerShell pour optimiser la performance d'...
 
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
Introduction au #MicrosoftGraph demarrez vite et livrez rapidemment #MWCP18
 
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
2018-10-17 J1 7D - Introduction au Microsoft Graph démarrez vite et livrez ra...
 
La mobilité dans Drupal
La mobilité dans DrupalLa mobilité dans Drupal
La mobilité dans Drupal
 
JSS2014 - StreamInsight
JSS2014 - StreamInsightJSS2014 - StreamInsight
JSS2014 - StreamInsight
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 

Plus de Fabrice Sznajderman

Lagom framework - Touraine Tech 2018
Lagom framework - Touraine Tech 2018Lagom framework - Touraine Tech 2018
Lagom framework - Touraine Tech 2018
Fabrice Sznajderman
 
The beauty of pictures
 The beauty of pictures The beauty of pictures
The beauty of pictures
Fabrice Sznajderman
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
Fabrice Sznajderman
 
Université des langages scala
Université des langages   scalaUniversité des langages   scala
Université des langages scala
Fabrice Sznajderman
 
Les monades Scala, Java 8
Les monades Scala, Java 8Les monades Scala, Java 8
Les monades Scala, Java 8
Fabrice Sznajderman
 
La gestion des droits numériques - CNAM
La gestion des droits numériques - CNAMLa gestion des droits numériques - CNAM
La gestion des droits numériques - CNAM
Fabrice Sznajderman
 
Paris jug option
Paris jug optionParis jug option
Paris jug option
Fabrice Sznajderman
 

Plus de Fabrice Sznajderman (7)

Lagom framework - Touraine Tech 2018
Lagom framework - Touraine Tech 2018Lagom framework - Touraine Tech 2018
Lagom framework - Touraine Tech 2018
 
The beauty of pictures
 The beauty of pictures The beauty of pictures
The beauty of pictures
 
Lagom : Reactive microservice framework
Lagom : Reactive microservice frameworkLagom : Reactive microservice framework
Lagom : Reactive microservice framework
 
Université des langages scala
Université des langages   scalaUniversité des langages   scala
Université des langages scala
 
Les monades Scala, Java 8
Les monades Scala, Java 8Les monades Scala, Java 8
Les monades Scala, Java 8
 
La gestion des droits numériques - CNAM
La gestion des droits numériques - CNAMLa gestion des droits numériques - CNAM
La gestion des droits numériques - CNAM
 
Paris jug option
Paris jug optionParis jug option
Paris jug option
 

Lagom, reactive framework(paris jug2017)

  • 1. Lagom Reactive microservices framework Lagom Reactive microservices framework Fabrice Sznajderman - @fsznajderman 14 mars 2017 @lagom
  • 2. Roadmap ● Microservices / Event Sourcing / CQRS ● Overview ● Principales fonctionnalités ● Live coding ● Next step
  • 3. 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
  • 4. Core concepts Microservices / Event Sourcing / CQRS
  • 7. 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
  • 12. CQRS
  • 13. CQRS ● Command ● Query ● Responsability ● Segregation
  • 15. Write (Command) : Event log. Modèle simple. Read (Query) : Dénormalisation, scalabillité, performance... CQRS
  • 16. CQRS
  • 17. Lagom Overview / Principales fonctionnalités / Live coding
  • 19. ● Construire un système de microservices ● Basé sur les principes réactifs ● Intégration dans l’environnement de développement Overview - Objectifs
  • 20. ● Coeur du framework est écrit en Scala ● API en Java 8 ● API en Scala 2.11.* Overview - Quel langage ?
  • 21. ● 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
  • 23. ● Description de l’API basée sur une interface ● Request / response synchrone ● Message asynchrone - Streaming Fonctionnalités - Service API
  • 24. 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)); } }
  • 25. ● 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
  • 26. Fonctionnalités - Persistance API public 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(); }
  • 27. ● ConductR pour la production ● Scalabilité ● Déploiement ● Monitoring Fonctionnalités - Environnement Production
  • 28. ● Consul / Zookeeper ● Treafik / HaProxy ● Docker ● Monitoring (traefik) Fonctionnalités - Environnement Production (free)
  • 29. ● 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
  • 30. 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
  • 33. ● Hello World ● Calculator - ConductR ● Sloak - CQRS / Events Sourcing ● Déploiement sans conductR - Etat des lieux Roadmap - Live coding
  • 34. 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