How to deal with long initialization of an Akka child actor?

后端 未结 3 873
醉酒成梦
醉酒成梦 2021-02-02 15:36

I have an actor which creates a child actor to perform some lengthy computations.

The problem is that the initialization of the child actor takes a few seconds and all

3条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-02 16:37

    I would suggest to send a "ready" message from the child actor to the parent and start sending messages to the child actor only after this message will be received. You can do it just in receive() method for simple use cases or you can use become or FSM to change parent actor behavior after the child will be initialized (for example, store the messages for the child in some intermediate storage and send them all when it will be ready).

提交回复
热议问题