How to guarantee sequentiality for forks in akka

前端 未结 1 933
半阙折子戏
半阙折子戏 2020-12-21 09:30

We\'re creating a chain of actors for every (small) incoming group of messages to guarantee their sequential processing and piping (groups are differentiating by common id).

相关标签:
1条回答
  • 2020-12-21 10:18

    The simpler solution is to store a future for last received message into the actor's state and chain it with previous future:

    def receive = process(Future{new Ack}) //completed future
    def process(prevAck: Future[Ack]): Receive = { //pseudocode
        case x => ...
            context become process(prevAck.flatMap(_ => A2orA4 ? msg))
    }
    

    So it will create chain of futures without any blocking. The chain will be erased after futures completion (except the last one).

    0 讨论(0)
提交回复
热议问题