Akka: Cleanup of dynamically created actors necessary when they have finished?

后端 未结 4 1845
甜味超标
甜味超标 2021-02-07 01:33

I have implemented an Actor system using Akka and its Java API UntypedActor. In it, one actor (type A) starts other actors (type B) dynamically on demand, using getContext

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-07 02:15

    In addition to Roland Kuhn's answer, rather than create a new actor for every request, you could create a predefined set of actors that share the same dispatcher, or you can use a router that distributes requests to a pool of actors.

    The Balancing Pool Router, for example, allows you to have a fixed set of actors of a particular type share the same mailbox:

    akka.actor.deployment {
      /parent/router9 {
        router = balancing-pool
        nr-of-instances = 5
      }
    }
    

    Read the documentation on dispatchers and on routing for further detail.

提交回复
热议问题