Playframework(13)Update Version and pick up the knowledge

本文介绍了如何从旧版Playframework升级到最新版本,并详细讲解了使用Typesafe Activator进行项目创建与部署的过程。同时,还介绍了Playframework中处理异步请求的方法及线程池配置。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Playframework(13)Update Version and pick up the knowledge

1. Pick up the Old Knowledge
Our company is using the old version http://downloads.typesafe.com/releases/play-2.0.4.zip
Just follow the blog and set up all these things.

>play eclipsify
Then can be import to eclipse

>play idea 
Import to intellij

deployment
>plan clean compile stage
>target/start
>target/start -DapplyEvolutions.default=true

Or

>play dist
>play -Dconfig.file=path/file dist

>start -Dconfig.url=http://conf.mycompany.cm/conf/prod.conf 
>start -Dhttp.port=9998 
>start -Dhttp.port=1234 -Dhttp.address=127.0.0.1

Handling Asynchronous Results
  def index = Action {
    val promiseOfResp = Akka.future {
      Ok("")
    }
    Async {
      promiseOfResp.map(resp => resp)
    }
  }

Thread Pool
https://www.playframework.com/documentation/2.3.1/ThreadPools
http://stackoverflow.com/questions/24579030/play-framework-what-happens-when-requests-exceeds-the-available-threads
https://www.playframework.com/documentation/2.1.0/ThreadPools
https://www.playframework.com/documentation/2.0.4/ScalaAsync

Based on the document, there is default thread pool configured to support multiple thread, but there is thread VS events. So the suggestion is to use events and threads.
Threads is configured based on the cores.
We use Promise to do asynchronous requests to support multiple events.

Threads For Spray
http://spray.io/documentation/1.2.1/spray-can/
http://spray.io/documentation/1.2.1/spray-can/configuration/
http://doc.akka.io/docs/akka/2.1.4/general/configuration.html?_ga=1.238217664.1729015399.1407273046

It seems to be 
default-dispatcher {
     type = “Dispatcher”
     executor = “fork-join-executor”
     for-join-executor{
          parallelism-min = 8
          parallelism-factor = 3.0 #ceil(available processors * factor)
          parallelism-max = 64
     }
}

2. Latest Play and Typesafe Activator
Download the latest activator
>wget http://downloads.typesafe.com/typesafe-activator/1.2.8/typesafe-activator-1.2.8-minimal.zip

Unzip it and place it in the working directory, add the command to the path.

>activator ui

Here is the source codes
https://github.com/typesafehub/activator

This command will be perfect.
>activator ui -Dhttp.address=0.0.0.0 -Dhttp.port=8888

That can build the project based on the ui. Or we do it in command line.
>activator new easyplay play-scala
>cd easyplay
>activator

Then the same thing, visit this page to go on
http://localhost:9000/


References:
Playframework 1~12
http://sillycat.iteye.com/blog/1743396
http://sillycat.iteye.com/blog/1750340
http://sillycat.iteye.com/blog/1750947
http://sillycat.iteye.com/blog/1751649
http://sillycat.iteye.com/blog/1752183
http://sillycat.iteye.com/blog/1752579
http://sillycat.iteye.com/blog/1753450
http://sillycat.iteye.com/blog/1754139
http://sillycat.iteye.com/blog/1754381
http://sillycat.iteye.com/blog/1756342
http://sillycat.iteye.com/blog/1757098
http://sillycat.iteye.com/blog/1774803


https://www.playframework.com/documentation/2.0.4/IDE
https://www.playframework.com/documentation/2.3.x/NewApplication

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值