簡體   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