-
Notifications
You must be signed in to change notification settings - Fork 0
Description
java.lang.UnsupportedOperationException: cannot create top-level actor from the outside on ActorSystem with custom user guardian
Feature/akka typed by tksugimoto · Pull Request #22 · lerna-stack/lerna-sample-payment-app
[info] java.lang.UnsupportedOperationException: cannot create top-level actor from the outside on ActorSystem with custom user guardian
1222
[info] at akka.actor.ActorSystemImpl.actorOf(ActorSystem.scala:901)
1223
[info] at lerna.util.akka.AtLeastOnceDelivery$.tellTo(AtLeastOnceDelivery.scala:120)
1224
[info] at jp.co.tis.lerna.payment.application.ecpayment.issuing.actor.PaymentActorSpec.$anonfun$new$18(PaymentActorSpec.scala:232)
問題の場所
val atLeastOnceDeliveryProxy = system.toClassic.actorOf(AtLeastOnceDelivery.props(destination.toClassic))
発生すると思われるコード
$ git grep system.*.actorOf */src/main
lerna-management/src/main/scala/lerna/management/stats/MetricsImpl.scala: private val actor: ActorRef = system.actorOf(MetricsActor.props())
lerna-util-akka/src/main/scala/lerna/util/akka/AtLeastOnceDelivery.scala: val atLeastOnceDeliveryProxy = system.actorOf(AtLeastOnceDelivery.props(destination))
lerna-util-akka/src/main/scala/lerna/util/akka/AtLeastOnceDelivery.scala: val atLeastOnceDeliveryProxy = system.actorOf(AtLeastOnceDelivery.props(destination))
lerna-util-akka/src/main/scala/lerna/util/akka/AtLeastOnceDelivery.scala: val atLeastOnceDeliveryProxy = system.toClassic.actorOf(AtLeastOnceDelivery.props(destination.toClassic)).toTyped
lerna-util-akka/src/main/scala/lerna/util/akka/AtLeastOnceDelivery.scala: val atLeastOnceDeliveryProxy = system.toClassic.actorOf(AtLeastOnceDelivery.props(destination.toClassic))
lerna-util-sequence/src/main/scala/lerna/util/sequence/CassandraSequenceFactory.scala: val actor = system.actorOf(
原因
if you need system.toClassic.actorOf you have to start it as akka.actor.ActorSystem, which you can adapt with .toTyped
typedSystem.toClassic.actorOf が使えるのは元々クラシックActorSystem の場合のみ。
対策
- クラシック Props を typed API (Behavior) に書き換える
- クラシック
akka.actor.ActorSystemから Behavior で Actor を作ることはakka.actor.typed.scaladsl.adapterを使いsystem.toTyped.systemActorOfを使うことで可能
- クラシック
- (クラシック) Extension 化する
Classic Akka Extensions • Akka Documentation- ExtendedActorSystem が提供され、
def systemActorOf(props: Props, name: String): ActorRefが使える- ※ typed Extension を使うと、
ActorSystem[_]しか得られず、クラシックなPropsから actor を作れず、 typed 化 or 一層挟む必要がある - 参考: 🐞fix: Make classic ClusterReplication an ActorSystem extension · lerna-stack/akka-entity-replication@0a5990a
- ※ typed Extension を使うと、
- ExtendedActorSystem が提供され、
関連
- v2.0.0 #11
v2.0.0 · Issue #11 · lerna-stack/lerna-app-library- Typed/lerna util akka #7
Typed/lerna util akka by tksugimoto · Pull Request #7 · lerna-stack/lerna-app-library
- Typed/lerna util akka #7
- Feature/akka typed Actor lerna-sample-payment-app#22 (comment)
Feature/akka typed by tksugimoto · Pull Request #22 · lerna-stack/lerna-sample-payment-app - Feature/akka typed actor system lerna-sample-payment-app#30
Feature/akka typed actor system by tksugimoto · Pull Request #30 · lerna-stack/lerna-sample-payment-app