为什么持久的PersistentActor方法不会返回Future?

时间:2015-08-30 22:30:31

标签: scala akka

我有一个理论问题。最近我写了这段代码:

class Account extends PersistentActor {
    def receiveCommand = {
        case Block(id, amount) => persist(Block(id, amount)){
            case Block(id, amount) =>
                persist(RevertBlock(id, s"Id ${id} already in processing", 
                  balance + amount))(_.revert())
        }
    }
    ...
}

看起来很糟糕。为什么方法persist将回调作为第二个参数而不是返回Future?

1 个答案:

答案 0 :(得分:0)

处理上下文。回调中的sender()始终有效,对于期货而言并非如此。