gpt4 book ai didi

akka-cluster - Akka文档尚不清楚如何获取ExtendedActorSystem以反序列化ActorRef

转载 作者:行者123 更新时间:2023-12-03 16:26:56 25 4
gpt4 key购买 nike

我正在尝试通过protobuf序列化/反序列化ActorRef。根据Akka的文档,唯一的方法是将ActorRef转换为String,然后将其转换回远程actor系统。

该文档提到使用ExtendedActorSystem进行反序列化(请参阅here)。但是,尚不清楚如何获取ExtendedActorSystem:

// Serialize
// (beneath toBinary)
val identifier: String = Serialization.serializedActorPath(theActorRef)

// Then just serialize the identifier however you like

// Deserialize
// (beneath fromBinary)
// ==== Where is this extendedSystem from? ====
val deserializedActorRef = extendedSystem.provider.resolveActorRef(identifier)
// Then just use the ActorRef

编辑

我在这里找到了这个问题: Akka (JVM): Serialize an actorref with protobuf within another message,其中提到将 ActorSystem转换为 ExtendedActorSystem。这是正确的方法吗?会一直有效吗?

最佳答案

亲爱的@stackoverflower,

每当您使用ActorSystem(...)时,它都会构建一个ActorSystemImpl的实例。

类型树如下所示:
ActorSystemImpl extends ExtendedActorSystem

ExtendedActorSystem implements ActorSystem
您可以使用类似的语句
val system: ExtendedActorSystem = ActorSystem(...).asInstanceOf[ExtendedActorSystem]
访问正确的类型自动完成功能。不幸的是,ActorSystemImpl的作用域为[akka]

关于akka-cluster - Akka文档尚不清楚如何获取ExtendedActorSystem以反序列化ActorRef,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44875606/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com