Akka远程可序列化警告

编程入门 行业动态 更新时间:2024-10-08 05:29:46
本文介绍了Akka远程可序列化警告的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在玩akka远程处理,并创建了一个小的Scala应用程序,该应用程序将消息发送到其他Scala应用程序。很好,接收方应用程序设法接收到消息,但是我收到了奇怪的序列化警告(如下所示)。我尝试按照 akka的文档配置序列化.io远程处理,但没有找到摆脱这些警告的设置。

I was playing with akka remoting and created a small Scala application which sends messages to other Scala apps. That was fine, the receiver application managed to receive the messages, however I got strange serialization warning (like below). I tried to configure serialization following the documentation of akka.io remoting, but didn't manage to find a setup which get rid of those warnings.

我虽然做错了一些,但克隆了akka / akka github repo,我 sbt run akka-samples / akka-sample-remote-scala。我很惊讶它们有相同的错误。

I though that I did something wrong and cloned akka/akka github repo, I sbt run akka-samples/akka-sample-remote-scala. I surprised that they have the same errors.

[WARN] [03/29/2016 16:53:40.137] [LookupSystem-akka .remote.default-remote-dispatcher-8] [akka.serialization.Serialization(akka:// LookupSystem)]对类[sample.remote.calculator.Subtract]使用默认的Java序列化程序,由于其性能影响,不建议使用。使用其他序列化程序或使用设置'akka.actor.warn-about-java-serializer-usage'禁用此警告。

[WARN] [03/29/2016 16:53:40.137] [LookupSystem-akka.remote.default-remote-dispatcher-8] [akka.serialization.Serialization(akka://LookupSystem)] Using the default Java serializer for class [sample.remote.calculator.Subtract] which is not recommended because of performance implications. Use another serializer or disable this warning using the setting 'akka.actor.warn-about-java-serializer-usage'

任何人都可以为我指出正确的方向?谢谢。

Anyone can point me the right direction? Thanks.

推荐答案

好吧,这不是一个错误,只是一个警告。 Akka使用Java序列化来处理用户消息,因此人们无需定义任何映射等即可快速入门。 但是您不想在生产中使用它,因为它相当慢。因此,如果您只是在玩耍,可以忽略警告(甚至可以按照消息中的说明在配置中将其禁用)。对于严肃的业务,请使用JSON, Avro ,Kryo,Protobuf ...

Well, it's not an error, it's just a warning. Akka uses the Java serialization for user messages so people get started quickly, without having to define any mappings or the like. But you don't want to use it in production, as it's pretty slow. So if you're just playing around, you can ignore the warning (or even disable it in the config as the message explains). For serious business, use JSON, Avro, Kryo, Protobuf...

在配置中定义自己的序列化器

Define your own serializer in the config

akka { actor { serializers { java = "akka.serialization.JavaSerializer" proto = "akka.remote.serialization.ProtobufSerializer" myown = "docs.serialization.MyOwnSerializer" } serialization-bindings { "java.lang.String" = java "docs.serialization.Customer" = java "com.google.protobuf.Message" = proto "docs.serialization.MyOwnSerializable" = myown "java.lang.Boolean" = myown } } }

您只需要指定接口名称或抽象的类基消息。如果存在歧义,即消息实现了几个配置的类,则将使用最具体的配置的类,即所有其他候选者都是超类之一。

You only need to specify the name of an interface or abstract base class of the messages. In case of ambiguity, i.e. the message implements several of the configured classes, the most specific configured class will be used, i.e. the one of which all other candidates are superclasses.

此内容取自 doc.akka.io/docs/akka/2.4.2/scala/serialization.html#serialization-scala

很棒的 Akka禅 演示,第7章。

更多推荐

Akka远程可序列化警告

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

发布评论

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

>www.elefans.com

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