SlideShare a Scribd company logo
1 of 30
Download to read offline
Play! Framework
Eduard Tudenhöfner
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Overview
● MVC Pattern
● Java & Scala API
● Stateless
● Built on Akka
Play Console
● play new my-app
● play compile | run | test | debug
● play clean-all
● play eclipse | idea
Application Layout
HTTP Routing
● URI to Controller mapping
GET /projects/:projectId/tasks controllers.Tasks.index(projectId: Long)
POST /projects/:projectId/tasks controllers.Tasks.add(projectId: Long, folder: String)
PUT /tasks/:task controllers.Tasks.update(task: Long)
DELETE /tasks/:task controllers.Tasks.delete(task: Long)
● pattern: <HTTP Method> <URI> <Controller>
State in Play!
● server is stateless
● state is stored on client
● session and flash scopes
○ for data that is required between subsequent HTTP
requests
○ cookie (max 4KB per User / only string values)
Important: The flash scope should only be used to transport success/error messages on
simple non-Ajax applications. As the data are just kept for the next request and because there
are no guarantees to ensure the request order in a complex Web application, the Flash scope is
subject to race conditions.
Model
● POJOs with generated getters/setters
● Play uses Active Record pattern
● EBean -> default ORM (JPA without
container)
Testing Support
● play test
● Helper classes to mock and fake almost
everything
● provides support for Selenium &
FluentLenium
Testing Support
Testing Support
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Error Handling
Error Handling
● Big Plus: detailed error messages shown in
browser -> no need to search log files
● errors can be in
○ Java/Scala class
○ Routes config
○ template code
○ ….
Error Handling
Error Handling
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Threaded
Threaded
● one thread assigned to each request
● any I/O is typically synchronous
● problems that might arise?
○ thread pool sizing -> too many/too few?!
○ Thread stack size with 64 Bit JVMs -> 1MB
○ thread might get blocked, waiting for another
service to complete
Evented
Evented
● one thread per CPU core
● basic idea: ensure that these scarce
resources are never blocked
● I/O is asynchronous
● blocking I/O mostly when talking to DBs
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Async Features
● idea: never block
● Play actions are async by default!
● Controllers return Result objects
● when async, return Promise<Result>
○ client is blocked - server is not blocked and serves
result when it’s computed
Note: Whether the action code returns a Result or a Promise<Result>, both kinds of returned object are
handled internally in the same way. There is a single kind of Action, which is asynchronous, and not two kinds
(a synchronous one and an asynchronous one). Returning a Promise is a technique for writing non-blocking
code.
Async Features
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Outline
● Getting Started
● Error Handling
● Threaded vs Evented
● Async Features
● Demo
● Summary
Summary
● High Developer Productivity
○ make a change -> refresh -> see the change
○ hot reload for all resources
● Built-in testing support
● Predictable Scalability
○ adheres to HTTP principles
○ non-blocking I/O support
● Commercial Support available through Typesafe & Zenexity
● Typesafe
○ makes it easier for large code bases
Summary
● Immature
○ Best Practices aren’t well defined
○ API is changing
○ Play 2 was entirely rewritten
● Not a Servlet
○ breaks away from the Servlet spec
● Build System (SBT)
○ hard to understand (even for Scala experts)
○ very powerful & flexible, but very steep learning curve
Thank you! - Questions?

More Related Content

What's hot

How to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingHow to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingSun-Li Beatteay
 
Introduction to K6
Introduction to K6Introduction to K6
Introduction to K6Knoldus Inc.
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]Ortus Solutions, Corp
 
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]Ortus Solutions, Corp
 
casperjs presentation
 casperjs presentation casperjs presentation
casperjs presentationAnsviaLab
 
CPAN Gems From The Far East
CPAN Gems From The Far EastCPAN Gems From The Far East
CPAN Gems From The Far Eastlestrrat
 
Kernel Recipes 2014 - Performance Does Matter
Kernel Recipes 2014 - Performance Does MatterKernel Recipes 2014 - Performance Does Matter
Kernel Recipes 2014 - Performance Does MatterAnne Nicolas
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUGslandelle
 
Schedulers and Timers in Akka
Schedulers and Timers in AkkaSchedulers and Timers in Akka
Schedulers and Timers in AkkaKnoldus Inc.
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascriptEman Mohamed
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Jan Gehring
 
Повний тестздець SPA + REST
Повний тестздець SPA + RESTПовний тестздець SPA + REST
Повний тестздець SPA + RESTStfalcon Meetups
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangEUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangPaweł Pikuła
 
How to achieve scalable environments using kubernetes and vmss on azure cloud
How to achieve scalable environments using kubernetes and vmss on azure cloudHow to achieve scalable environments using kubernetes and vmss on azure cloud
How to achieve scalable environments using kubernetes and vmss on azure cloudNoam Shochat
 
Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiJackson Tian
 

What's hot (19)

How to make your ruby code faster with multithreading
How to make your ruby code faster with multithreadingHow to make your ruby code faster with multithreading
How to make your ruby code faster with multithreading
 
Introduction to K6
Introduction to K6Introduction to K6
Introduction to K6
 
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
Brad wood - 5 CommandBox Modules You Should Be Using [Into The Box 2020]
 
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
Brad wood - Integrating MVC Into Legacy [Into The Box 2020]
 
casperjs presentation
 casperjs presentation casperjs presentation
casperjs presentation
 
CPAN Gems From The Far East
CPAN Gems From The Far EastCPAN Gems From The Far East
CPAN Gems From The Far East
 
Kernel Recipes 2014 - Performance Does Matter
Kernel Recipes 2014 - Performance Does MatterKernel Recipes 2014 - Performance Does Matter
Kernel Recipes 2014 - Performance Does Matter
 
NullMQ @ PDX
NullMQ @ PDXNullMQ @ PDX
NullMQ @ PDX
 
Blocks, procs && lambdas
Blocks, procs && lambdasBlocks, procs && lambdas
Blocks, procs && lambdas
 
Gatling - Bordeaux JUG
Gatling - Bordeaux JUGGatling - Bordeaux JUG
Gatling - Bordeaux JUG
 
Schedulers and Timers in Akka
Schedulers and Timers in AkkaSchedulers and Timers in Akka
Schedulers and Timers in Akka
 
Asynchronous javascript
 Asynchronous javascript Asynchronous javascript
Asynchronous javascript
 
Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013Rex - Lightning Talk yapc.eu 2013
Rex - Lightning Talk yapc.eu 2013
 
Zero mq logs
Zero mq logsZero mq logs
Zero mq logs
 
Повний тестздець SPA + REST
Повний тестздець SPA + RESTПовний тестздець SPA + REST
Повний тестздець SPA + REST
 
Capistrano demo
Capistrano demoCapistrano demo
Capistrano demo
 
EUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old ErlangEUC2015 - Load testing XMPP servers with Plain Old Erlang
EUC2015 - Load testing XMPP servers with Plain Old Erlang
 
How to achieve scalable environments using kubernetes and vmss on azure cloud
How to achieve scalable environments using kubernetes and vmss on azure cloudHow to achieve scalable environments using kubernetes and vmss on azure cloud
How to achieve scalable environments using kubernetes and vmss on azure cloud
 
Ruby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay ShanghaiRuby vs Node ShiningRay Shanghai
Ruby vs Node ShiningRay Shanghai
 

Similar to Play Framework

Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js PresentationExist
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleDmytro Semenov
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadKrivoy Rog IT Community
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in JavaLukas Steinbrecher
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java codeAttila Balazs
 
Asynchronous programming with Java & Spring
Asynchronous programming with Java & SpringAsynchronous programming with Java & Spring
Asynchronous programming with Java & SpringRavindra Ranwala
 
On component interface
On component interfaceOn component interface
On component interfaceLaurence Chen
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with GatlingPetr Vlček
 
Node.js streams talk
Node.js streams talkNode.js streams talk
Node.js streams talkzladuric
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)Tech in Asia ID
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With GatlingKnoldus Inc.
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openrestyTavish Naruka
 
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияКак мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияPositive Hack Days
 
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farm
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farmKernel Recipes 2016 - Speeding up development by setting up a kernel build farm
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farmAnne Nicolas
 
Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012mumrah
 

Similar to Play Framework (20)

Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Netty training
Netty trainingNetty training
Netty training
 
Netty training
Netty trainingNetty training
Netty training
 
Nodejs
NodejsNodejs
Nodejs
 
Node.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scaleNode.js Web Apps @ ebay scale
Node.js Web Apps @ ebay scale
 
kranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High loadkranonit S06E01 Игорь Цинько: High load
kranonit S06E01 Игорь Цинько: High load
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in Java
 
Varnish - PLNOG 4
Varnish - PLNOG 4Varnish - PLNOG 4
Varnish - PLNOG 4
 
Performance optimization techniques for Java code
Performance optimization techniques for Java codePerformance optimization techniques for Java code
Performance optimization techniques for Java code
 
Asynchronous programming with Java & Spring
Asynchronous programming with Java & SpringAsynchronous programming with Java & Spring
Asynchronous programming with Java & Spring
 
On component interface
On component interfaceOn component interface
On component interface
 
Load testing in Zonky with Gatling
Load testing in Zonky with GatlingLoad testing in Zonky with Gatling
Load testing in Zonky with Gatling
 
Node.js streams talk
Node.js streams talkNode.js streams talk
Node.js streams talk
 
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
"You Don't Know NODE.JS" by Hengki Mardongan Sihombing (Urbanhire)
 
Gatling
Gatling Gatling
Gatling
 
Performance Test Automation With Gatling
Performance Test Automation  With GatlingPerformance Test Automation  With Gatling
Performance Test Automation With Gatling
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openresty
 
Как мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управленияКак мы взломали распределенные системы конфигурационного управления
Как мы взломали распределенные системы конфигурационного управления
 
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farm
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farmKernel Recipes 2016 - Speeding up development by setting up a kernel build farm
Kernel Recipes 2016 - Speeding up development by setting up a kernel build farm
 
Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012Introduction to ZooKeeper - TriHUG May 22, 2012
Introduction to ZooKeeper - TriHUG May 22, 2012
 

Recently uploaded

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfOverkill Security
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 

Recently uploaded (20)

Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 

Play Framework

  • 2. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 3. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 4. Overview ● MVC Pattern ● Java & Scala API ● Stateless ● Built on Akka
  • 5. Play Console ● play new my-app ● play compile | run | test | debug ● play clean-all ● play eclipse | idea
  • 7. HTTP Routing ● URI to Controller mapping GET /projects/:projectId/tasks controllers.Tasks.index(projectId: Long) POST /projects/:projectId/tasks controllers.Tasks.add(projectId: Long, folder: String) PUT /tasks/:task controllers.Tasks.update(task: Long) DELETE /tasks/:task controllers.Tasks.delete(task: Long) ● pattern: <HTTP Method> <URI> <Controller>
  • 8. State in Play! ● server is stateless ● state is stored on client ● session and flash scopes ○ for data that is required between subsequent HTTP requests ○ cookie (max 4KB per User / only string values) Important: The flash scope should only be used to transport success/error messages on simple non-Ajax applications. As the data are just kept for the next request and because there are no guarantees to ensure the request order in a complex Web application, the Flash scope is subject to race conditions.
  • 9. Model ● POJOs with generated getters/setters ● Play uses Active Record pattern ● EBean -> default ORM (JPA without container)
  • 10. Testing Support ● play test ● Helper classes to mock and fake almost everything ● provides support for Selenium & FluentLenium
  • 13. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 15. Error Handling ● Big Plus: detailed error messages shown in browser -> no need to search log files ● errors can be in ○ Java/Scala class ○ Routes config ○ template code ○ ….
  • 18. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 20. Threaded ● one thread assigned to each request ● any I/O is typically synchronous ● problems that might arise? ○ thread pool sizing -> too many/too few?! ○ Thread stack size with 64 Bit JVMs -> 1MB ○ thread might get blocked, waiting for another service to complete
  • 22. Evented ● one thread per CPU core ● basic idea: ensure that these scarce resources are never blocked ● I/O is asynchronous ● blocking I/O mostly when talking to DBs
  • 23. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 24. Async Features ● idea: never block ● Play actions are async by default! ● Controllers return Result objects ● when async, return Promise<Result> ○ client is blocked - server is not blocked and serves result when it’s computed Note: Whether the action code returns a Result or a Promise<Result>, both kinds of returned object are handled internally in the same way. There is a single kind of Action, which is asynchronous, and not two kinds (a synchronous one and an asynchronous one). Returning a Promise is a technique for writing non-blocking code.
  • 26. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 27. Outline ● Getting Started ● Error Handling ● Threaded vs Evented ● Async Features ● Demo ● Summary
  • 28. Summary ● High Developer Productivity ○ make a change -> refresh -> see the change ○ hot reload for all resources ● Built-in testing support ● Predictable Scalability ○ adheres to HTTP principles ○ non-blocking I/O support ● Commercial Support available through Typesafe & Zenexity ● Typesafe ○ makes it easier for large code bases
  • 29. Summary ● Immature ○ Best Practices aren’t well defined ○ API is changing ○ Play 2 was entirely rewritten ● Not a Servlet ○ breaks away from the Servlet spec ● Build System (SBT) ○ hard to understand (even for Scala experts) ○ very powerful & flexible, but very steep learning curve
  • 30. Thank you! - Questions?