Akka.io: Thread per Actor

2019-06-11 17:02发布

There is a requirement to run 1 thousand operations asynchoniosly, I've chosen to use Akka. Warpping in Actor Ref executor and sending 1 thousand messages to ref.

How can I be sure that:

  • all 1 thousand messages will be dispatched in asnc way
  • each will hold the separate, in-depended thread (that is requirement because of io usage).

标签: scala akka
3条回答
一夜七次
2楼-- · 2019-06-11 17:18

Try to use PinnedDispatcher

Configuration example & code is here

No blocking until bounded mailbox will be used

查看更多
ゆ 、 Hurt°
3楼-- · 2019-06-11 17:32

You can use the PinnedDispatcher to guarantee one thread per actor, and everything in Akka is async, so you can be guaranteed the messages are async. If you send your messages using the ! operator, the message is sent in a fire-and-forget manner.

See this for more details.

查看更多
smile是对你的礼貌
4楼-- · 2019-06-11 17:40

Thanks all for the responses, actually for my case combination of RoundRobinRouter (where number of routes is equal to number of expected threads) and PinnedDispatcher with flag thread-pool-executor.allow-core-timeout=off is working fine.

查看更多
登录 后发表回答