Akka(JVM):在另一条消息中使用 protobuf 序列化 actorref

Akka (JVM): Serialize an actorref with protobuf within another message

我有以下要用 protobuf 序列化的 Scala 对象:

case class Worker(id: String, ref: ActorRef)

我的理解是 Akka 附带了一个 ProtobufSerializer,我可以用它来序列化 from/to ActorRef。因此,我在原型文件中定义了以下消息:

message Worker {
    string id = 1;
    bytes ref = 2;
}

然而,当我需要序列化这些消息时,静态方法 ProtobufSerializer 采用了我手头没有的 ExtentendActorSystem(只有通过我的 actor 的 context.system 属性的 ActorSystem)。我不确定如何将我的对象实际序列化为 protobuf,反之亦然。

我不确定在哪些情况下是正确的,但我能够简单地将我的 ActorSystem 转换为 ExtendedActorSystem。在我的具体情况下(我将 Akka Persistence 与 Akka Singleton 一起使用)它似乎工作正常。