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

编程入门 行业动态 更新时间:2024-10-12 05:55:42
本文介绍了Akka(JVM):在另一条消息中使用protobuf序列化actorref的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

I have the following scala object that I would like to serialize with protobuf:

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

我的理解是Akka带有ProtobufSerializer,可用于从中序列化/到ActorRef。因此,我在原型文件中定义了以下消息:

My understanding is that Akka comes with a ProtobufSerializer that I can use to serialize from/to ActorRef. Therefore I defined the following message in a proto file:

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

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

However the static methods ProtobufSerializer take an ExtentendActorSystem that I do not have at hand when I need to serialize those messages (only an ActorSystem through the context.system attribute of my actor). I am not sure how to actually serialize my object to protobuf and the other way around.

推荐答案

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

I am not sure in which cases it is true, but I was able to simply cast my ActorSystem to an ExtendedActorSystem. In my specific case (I am using Akka Persistence with Akka Singleton) it seems to work fine.

更多推荐

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

本文发布于:2023-11-25 02:33:23,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1627973.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:消息   序列化   JVM   Akka   protobuf

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!