scala - Akka 演员没有收到案例类 [Akka 远程处理](序列化问题)
问题描述
我有一个应用程序,它运行一个带有主管的演员系统,可以通过 akka 远程处理接收消息。从远程参与者系统发送的消息是案例类,例如:
case class SupervisorStartChannel(channelName: String) extends SupervisorRequest
case class SupervisorShutdown() extends SupervisorRequest
在我的接收中,我有以下内容:
def receive: Actor.Receive = LoggingReceive ({
case SupervisorListChannels =>
listChannels()
case SupervisorReportComponents =>
sender ! loadConfiguredComponents()
case SupervisorStartChannel(channelName) =>
sender ! startChannelByName(channelName)
case SupervisorShutdown =>
log.info("Shutdown received.")
sender ! SupervisorAck
context.system.terminate()
case _ =>
replayError(s"$supervisorName can't process an empty command.")
}: Receive) andThen metered.Receive
如果我从主管运行的同一个actor系统内部发送一个SupervisorShutdown,它会进入正确的案例,但是当从远程系统发送SupervisorShutdown()时,它会进入案例_。虽然发送 SupervisorStartChannel(channel1) 工作正常。
编辑:运行一些测试后,我发现问题来自于case class SupervisorShutdown() extends SupervisorRequest
. Akka 使用默认的 Java 序列化程序进行远程处理,这就是导致它的原因。
知道是什么原因造成的吗?
解决方案
正如@dyrkin 建议的那样,在运行了几个测试之后,通过使用SupervisorShutdown()
而不是解决了这个问题SupervisorShutdown
,然后也与SupervisorShutdown()
.
推荐阅读
- javascript - 左对齐文本,但如果左边太长,则以 ... 为前缀
- r - 在 R 中打开 Biostrings 包上的 fas 格式文件
- neo4j - 如何处理密码查询常见节
- xpath - 找不到正确的 Xpath
- php - 在插入数据之前检查带有条件的特定列的 SUM
- python - 需要帮助理解这个关于 Python 中相对导入和绝对导入的问题
- javascript - Svg.JS 中的图像在动画后消失
- nginx - Nginx + Gunicorn + Flask 静态资产 404
- javascript - 通过节点js将数据更新到firebase项目列表时检查更新结果
- javascript - 直方图平均值在循环中不改变