SlideShare uma empresa Scribd logo
1 de 13
Baixar para ler offline
Microservices in Play & Akka 
Łukasz Sowa @luksow 
Jacek Głodek @jacekglodek
Play Framework 
● General purpose 
● (Aims to be) fully-blown web framework 
● Part of Typesafe Reactive Platform 
● For Java & Scala 
● Popular (LinkedIn, Guardian, Klout, …) 
● Not very well-suited for microservices... 
● but still popular :)
Play Framework 
● Rails-like (M)VC 
● Routes => Controllers => Views
Play Framework
Routes (conf/routes) 
● Type safe! 
● VERB [path with params] [controller action] 
– GET / controllers.OpenGraphFetcher.index 
– GET /clients/:id controllers.ClientsController.show(id: Long) 
– PUT /orders/:clientid controllers.OrdersController.create(clientId: Int) 
● Body params (POST, PUT etc.) have to be 
handled by Play forms or manually (ugly!)
Controllers (app/controllers/*) 
● Composable Actions 
– Action: Request[A] => Result 
– DBAction: Session => Result 
– AuthAction: RequestWithUser[A] => Result 
– … 
● Can be async
Views (app/views/*) 
● Type safe templating language (twirl) 
● Meh (aka leave it to frontenders)
Coding! 
1) Clone & run sample project 
2) Add action that takes two params (login: 
String, authToken: String), wire it to routes, test 
3) Try authenticate your request with Redis
OpenGraph Info Fetcher 
● Given list of URLs return OG info 
● Synchronous? (request - response) 
● Waiting for all OGs to fetch 
● How to handle failure? 
● Or maybe polling? 
● No, websockets! 
● Answers ASAP 
● Failure? Just screw it
WebSockets 
● Async of the web! 
● Almost like good ol' TCP (BSD) sockets 
Play-flavoured websockets: 
● Iteratees (FP black magic, good for streams) 
● Actors (❤, good for messages)
Akka 
● Toolkit for distributed & concurrent systems 
● Based on concept of actor and messaging 
Actor: 
● Encapsulates mutable state 
● Reacts to messages 
● Sends messages to other actors it knows: 
● By address/name 
● Because they send him message 
● Because they were created by it 
● ...
Actors in Akka 
● Live in systems 
● Can be distributed in space & time 
● Process their messages sequentially 
● No guarantees of message delivery/processing 
● Can form tree-like hierarchies => supervision
Coding! 
1) Write echo websocket using Akka Actors 
2) Test it in web browser 
3) Write not-so-stringly-typed websocket 
4) Test it in web browser 
5) Write proper types for task 
6) Implement OG fetching 
7) Test it in web browser 
8) (For brave & ambitious) Implement caching

Mais conteúdo relacionado

Mais procurados

Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
Ngoc Dao
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
Ovidiu Dimulescu
 

Mais procurados (20)

Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1Your First Scala Web Application using Play 2.1
Your First Scala Web Application using Play 2.1
 
Asynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and JavaAsynchronous Web Programming with HTML5 WebSockets and Java
Asynchronous Web Programming with HTML5 WebSockets and Java
 
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
Searching for the framework of my dreams in node.js ecosystem by Mykyta Semen...
 
Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017Full stack development with node and NoSQL - All Things Open - October 2017
Full stack development with node and NoSQL - All Things Open - October 2017
 
Xitrum HOWTOs
Xitrum HOWTOsXitrum HOWTOs
Xitrum HOWTOs
 
Building a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless frameworkBuilding a serverless company on AWS lambda and Serverless framework
Building a serverless company on AWS lambda and Serverless framework
 
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
Lucio Grenzi - Building serverless applications on the Apache OpenWhisk platf...
 
Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014Xitrum @ Scala Matsuri Tokyo 2014
Xitrum @ Scala Matsuri Tokyo 2014
 
Vert.x vs akka
Vert.x vs akkaVert.x vs akka
Vert.x vs akka
 
GWT Web Socket and data serialization
GWT Web Socket and data serializationGWT Web Socket and data serialization
GWT Web Socket and data serialization
 
Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)Jolokia - JMX on Capsaicin (Devoxx 2011)
Jolokia - JMX on Capsaicin (Devoxx 2011)
 
Node.js, toy or power tool?
Node.js, toy or power tool?Node.js, toy or power tool?
Node.js, toy or power tool?
 
Scaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWSScaling a MeteorJS SaaS app on AWS
Scaling a MeteorJS SaaS app on AWS
 
Play + scala + reactive mongo
Play + scala + reactive mongoPlay + scala + reactive mongo
Play + scala + reactive mongo
 
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
Dan Persa, Maximilian Fellner - The recipe for scalable frontends - Codemotio...
 
Realtime web application with java
Realtime web application with javaRealtime web application with java
Realtime web application with java
 
Windows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside worldWindows 8 Metro apps and the outside world
Windows 8 Metro apps and the outside world
 
Using Play Framework 2 in production
Using Play Framework 2 in productionUsing Play Framework 2 in production
Using Play Framework 2 in production
 
Develop realtime web with Scala and Xitrum
Develop realtime web with Scala and XitrumDevelop realtime web with Scala and Xitrum
Develop realtime web with Scala and Xitrum
 
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
Carlo Sciolla - Above and beyond type systems with clojure.spec - Codemotion ...
 

Destaque

Akka persistence webinar
Akka persistence webinarAkka persistence webinar
Akka persistence webinar
patriknw
 

Destaque (12)

Building Micro-Services with Scala
Building Micro-Services with ScalaBuilding Micro-Services with Scala
Building Micro-Services with Scala
 
Microservices in Scala - theory & practice
Microservices in Scala - theory & practiceMicroservices in Scala - theory & practice
Microservices in Scala - theory & practice
 
Microservices - opportunities, dilemmas and problems
Microservices - opportunities, dilemmas and problemsMicroservices - opportunities, dilemmas and problems
Microservices - opportunities, dilemmas and problems
 
Microservices in Scala: Spray
Microservices in Scala: SprayMicroservices in Scala: Spray
Microservices in Scala: Spray
 
Play Framework 2.5
Play Framework 2.5Play Framework 2.5
Play Framework 2.5
 
Truly agile company
Truly agile companyTruly agile company
Truly agile company
 
Microservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problemsMicroservices 101: opportunities, dilemmas and problems
Microservices 101: opportunities, dilemmas and problems
 
Akka persistence webinar
Akka persistence webinarAkka persistence webinar
Akka persistence webinar
 
Practical Akka HTTP - introduction
Practical Akka HTTP - introductionPractical Akka HTTP - introduction
Practical Akka HTTP - introduction
 
Reactive microservices with play and akka
Reactive microservices with play and akkaReactive microservices with play and akka
Reactive microservices with play and akka
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
 
REST vs. Messaging For Microservices
REST vs. Messaging For MicroservicesREST vs. Messaging For Microservices
REST vs. Messaging For Microservices
 

Semelhante a Microservices in Scala: Play Framework

Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
Demi Ben-Ari
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present future
lolopetit
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
Fwdays
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
Sagiv Ofek
 

Semelhante a Microservices in Scala: Play Framework (20)

Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
Javascript Update May 2013
Javascript Update May 2013Javascript Update May 2013
Javascript Update May 2013
 
Node.js streams talk
Node.js streams talkNode.js streams talk
Node.js streams talk
 
Introduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actorsIntroduction to concurrent programming with akka actors
Introduction to concurrent programming with akka actors
 
Introduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actorsIntroduction to concurrent programming with Akka actors
Introduction to concurrent programming with Akka actors
 
Play Framework
Play FrameworkPlay Framework
Play Framework
 
Scala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache sparkScala like distributed collections - dumping time-series data with apache spark
Scala like distributed collections - dumping time-series data with apache spark
 
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияКак мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управления
 
Counterclockwise past present future
Counterclockwise  past present futureCounterclockwise  past present future
Counterclockwise past present future
 
Dart the Better JavaScript
Dart the Better JavaScriptDart the Better JavaScript
Dart the Better JavaScript
 
Road to sbt 1.0 paved with server
Road to sbt 1.0   paved with serverRoad to sbt 1.0   paved with server
Road to sbt 1.0 paved with server
 
Dragoncraft Architectural Overview
Dragoncraft Architectural OverviewDragoncraft Architectural Overview
Dragoncraft Architectural Overview
 
2017 DevSecCon ZAP Scripting Workshop
2017 DevSecCon ZAP Scripting Workshop2017 DevSecCon ZAP Scripting Workshop
2017 DevSecCon ZAP Scripting Workshop
 
DevSecCon London 2017: zap scripting workshop by Simon Bennetts
DevSecCon London 2017: zap scripting workshop by Simon BennettsDevSecCon London 2017: zap scripting workshop by Simon Bennetts
DevSecCon London 2017: zap scripting workshop by Simon Bennetts
 
Jinx - Malware 2.0
Jinx - Malware 2.0Jinx - Malware 2.0
Jinx - Malware 2.0
 
A Life of breakpoint
A Life of breakpointA Life of breakpoint
A Life of breakpoint
 
See Hudson Run, Run Hudson, Run [SELF 2010]
See Hudson Run, Run Hudson, Run [SELF 2010]See Hudson Run, Run Hudson, Run [SELF 2010]
See Hudson Run, Run Hudson, Run [SELF 2010]
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
 
Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"Philip Shurpik "Architecting React Native app"
Philip Shurpik "Architecting React Native app"
 
Node.js for Rubists
Node.js for RubistsNode.js for Rubists
Node.js for Rubists
 

Último

%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
masabamasaba
 

Último (20)

Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni%in Benoni+277-882-255-28 abortion pills for sale in Benoni
%in Benoni+277-882-255-28 abortion pills for sale in Benoni
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Toronto Psychic Readings, Attraction spells,Brin...
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
%in Rustenburg+277-882-255-28 abortion pills for sale in Rustenburg
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
Artyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptxArtyushina_Guest lecture_YorkU CS May 2024.pptx
Artyushina_Guest lecture_YorkU CS May 2024.pptx
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security ProgramWSO2CON 2024 - How to Run a Security Program
WSO2CON 2024 - How to Run a Security Program
 
WSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaSWSO2CON 2024 Slides - Open Source to SaaS
WSO2CON 2024 Slides - Open Source to SaaS
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
MarTech Trend 2024 Book : Marketing Technology Trends (2024 Edition) How Data...
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
What Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the SituationWhat Goes Wrong with Language Definitions and How to Improve the Situation
What Goes Wrong with Language Definitions and How to Improve the Situation
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 

Microservices in Scala: Play Framework

  • 1. Microservices in Play & Akka Łukasz Sowa @luksow Jacek Głodek @jacekglodek
  • 2. Play Framework ● General purpose ● (Aims to be) fully-blown web framework ● Part of Typesafe Reactive Platform ● For Java & Scala ● Popular (LinkedIn, Guardian, Klout, …) ● Not very well-suited for microservices... ● but still popular :)
  • 3. Play Framework ● Rails-like (M)VC ● Routes => Controllers => Views
  • 5. Routes (conf/routes) ● Type safe! ● VERB [path with params] [controller action] – GET / controllers.OpenGraphFetcher.index – GET /clients/:id controllers.ClientsController.show(id: Long) – PUT /orders/:clientid controllers.OrdersController.create(clientId: Int) ● Body params (POST, PUT etc.) have to be handled by Play forms or manually (ugly!)
  • 6. Controllers (app/controllers/*) ● Composable Actions – Action: Request[A] => Result – DBAction: Session => Result – AuthAction: RequestWithUser[A] => Result – … ● Can be async
  • 7. Views (app/views/*) ● Type safe templating language (twirl) ● Meh (aka leave it to frontenders)
  • 8. Coding! 1) Clone & run sample project 2) Add action that takes two params (login: String, authToken: String), wire it to routes, test 3) Try authenticate your request with Redis
  • 9. OpenGraph Info Fetcher ● Given list of URLs return OG info ● Synchronous? (request - response) ● Waiting for all OGs to fetch ● How to handle failure? ● Or maybe polling? ● No, websockets! ● Answers ASAP ● Failure? Just screw it
  • 10. WebSockets ● Async of the web! ● Almost like good ol' TCP (BSD) sockets Play-flavoured websockets: ● Iteratees (FP black magic, good for streams) ● Actors (❤, good for messages)
  • 11. Akka ● Toolkit for distributed & concurrent systems ● Based on concept of actor and messaging Actor: ● Encapsulates mutable state ● Reacts to messages ● Sends messages to other actors it knows: ● By address/name ● Because they send him message ● Because they were created by it ● ...
  • 12. Actors in Akka ● Live in systems ● Can be distributed in space & time ● Process their messages sequentially ● No guarantees of message delivery/processing ● Can form tree-like hierarchies => supervision
  • 13. Coding! 1) Write echo websocket using Akka Actors 2) Test it in web browser 3) Write not-so-stringly-typed websocket 4) Test it in web browser 5) Write proper types for task 6) Implement OG fetching 7) Test it in web browser 8) (For brave & ambitious) Implement caching