我正在尝试使用 Futures 和 Akka 主管开发应用程序,但是当 A 未来向参与者返回失败时,其主管没有收到异常。
这是我的代码。
1) 监督演员
class TransaccionActorSupervisor() extends Actor with ActorLogging {
val actor: ActorRef = context.actorOf(Props[TransaccionActor].withRouter(RoundRobinPool(nrOfInstances = 5)), "transaccion-actor")
def receive = {
case msg: Any => actor forward msg
}
override val supervisorStrategy = OneForOneStrategy() {
case exception =>
println("<<<<<<<<<<<<<<<<<<< IN SUPERVISOR >>>>>>>>>>>>>>>>>>>>>>>>>>>>")
Restart
}
}
监制演员
Class TransaccionActor() extends Actor with ActorLogging {
implicit val _: ExecutionContext = context.dispatcher
val transaccionAdapter = (new TransaccionComponentImpl with TransaccionRepositoryComponentImpl).adapter
def receive = {
case msg: GetTransaccionById =>
val currentSender: ActorRef = sender()
transaccionAdapter.searchTransaction(msg.id).onComplete {
case Success(transaction) => currentSender ! transaction
case Failure(error) => throw error
}
}
我究竟做错了什么?
非常感谢大家!