Akka远程可序列化警告 [英] akka-remote serializable warning

查看:353
本文介绍了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.

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

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

这篇关于Akka远程可序列化警告的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆