繁体   English   中英

Akka演员和消息节流

[英]Akka Actors and message Throttling

我正在尝试针对一个非常老的数据库编写一些代码,如果数据库受到很大的破坏,它将崩溃。

我正在寻找使演员每秒处理不超过X条消息的方法。

现在,我猜actor的默认实现是它尽可能快地处理其消息框中的消息。

但是我想知道是否有一种方法可以配置我的actor,以使来自actor消息队列的消息每秒限制为“ X”个消息。

您正在寻找一个TimerBasedThrottler

val printer = system.actorOf(Props[PrintActor])

// The throttler for this example, setting the rate
val throttler = system.actorOf(Props(
  classOf[TimerBasedThrottler],
  3 msgsPer 1.second))
throttler ! SetTarget(Some(printer))

然后通过节流阀ActorRef发送消息。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM