`
sillycat
  • 浏览: 2491863 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

Play framework with Akka Throttle for Output

 
阅读更多
Play framework with Akka Throttle for Output

1 AKKA Version
First of all, check with AKKA version I am using in play framework 2.4.3. I knew the version of AKKA really matters.

In my play framework project
> activator

activator> show compile:dependencyClasspath

It will list all the dependency jars.
akka-actor_2.10-2.3.13.jar

akka-slf4j_2.10-2.3.13.jar

So the version is AKKA 2.3.13.

2 Throttling Actor Messages
Add this in the dependency
  "com.typesafe.akka" %% "akka-contrib" % "2.3.13",

Initiate the Akka as follow
  val contextIOActor = Akka.system.actorOf(ContextIOActor.props, name = "contextio-actor")
  val contextIOThrottler = Akka.system.actorOf(Props(classOf[TimerBasedThrottler], contextio_throttle msgsPer 60.second), name = "conetxt-io-throttler")
  contextIOThrottler ! SetTarget(Some(contextIOActor))

Then all we need to do is to send message to the contextIOThrottler, it will just throttle that and redirect the message to target.

References:
http://stackoverflow.com/questions/31112397/print-akka-version-in-play-framework-2-4-1

http://doc.akka.io/docs/akka/2.3.13/contrib/throttle.html

http://letitcrash.com/post/28901663062/throttling-messages-in-akka-2

http://www.michaelpollmeier.com/akka-work-pulling-pattern/

http://www.michaelpollmeier.com/akka-work-pulling-pattern-to-throttle-work/

http://doc.akka.io/api/akka/2.3.13/index.html#akka.contrib.throttle.TimerBasedThrottler

https://github.com/jonasanso/throttling/blob/5102d35f9abdf0cb15732a1cef0e4c92c4cca59c/app/controllers/Application.scala
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics