【发布时间】:2013-12-13 05:00:17
【问题描述】:
我正在研究一个 Akka-Remoting 示例。在将序列化支持配置到 application.conf 文件之前,它运行良好。但是,启用序列化后,消息无法正确传递。
在接收和发送消息时,我可以在远程和客户端应用程序上看到 DeadLetter 的日志。我认为消息正在交换,但没有传递给正确的参与者。
这是在akka-mircokernel中运行的远程计算器的conf文件。
remoteCalculator {
akka {
actor {
#serialize-messages = on
#No need to define serializers: java and protobuf are supported by Akka.
serializers {
java = "akka.serialization.JavaSerializer"
#akka-containers = "akka.remote.serialization.MessageContainerSerializer"
proto = "akka.remote.serialization.ProtobufSerializer"
#daemon-create = "akka.remote.serialization.DaemonMsgCreateSerializer"
}
serialization-bindings {
#"akka.actor.ActorSelectionMessage" = akka-containers
#"com.google.protobuf.GeneratedMessage" = proto
#"akka.remote.DaemonMsgCreate" = daemon-create
"java.lang.Integer" = proto
"scala.Int" = proto
"akka.example.MathOp" = proto
#"akka.example.Add" = proto
#"akka.example.Subtract" = proto
#"akka.example.Multiply" = proto
#"akka.example.Divide" = proto
"akka.example.MathResult" = proto
#"akka.example.AddResult" = proto
#"akka.example.SubtractResult" = proto
#"akka.example.MultiplicationResult" = proto
#"akka.example.DivisionResult" = proto
}
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
log-received-messages = on
log-sent-messages = on
log-remote-lifecycle-events = on
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "IGLR000PBG3K8Y-ubuntu"
port = 2555
log-received-messages = on
log-sent-messages = on
log-remote-lifecycle-events = on
}
}
}
}
以及计算器客户端应用程序的 conf 文件
LocalSys {
akka {
actor {
#serialize-messages = on
#No need to define serializers: java and protobuf are supported by Akka.
serializers {
java = "akka.serialization.JavaSerializer"
#akka-containers = "akka.remote.serialization.MessageContainerSerializer"
proto = "akka.remote.serialization.ProtobufSerializer"
#daemon-create = "akka.remote.serialization.DaemonMsgCreateSerializer"
}
serialization-bindings {
#"akka.actor.ActorSelectionMessage" = akka-containers
#"com.google.protobuf.GeneratedMessage" = proto
#"akka.remote.DaemonMsgCreate" = daemon-create
"java.lang.Integer" = proto
"scala.Int" = proto
"akka.example.MathOp" = proto
#"akka.example.Add" = proto
#"akka.example.Subtract" = proto
#"akka.example.Multiply" = proto
#"akka.example.Divide" = proto
"akka.example.MathResult" = proto
#"akka.example.AddResult" = proto
#"akka.example.SubtractResult" = proto
#"akka.example.MultiplicationResult" = proto
#"akka.example.DivisionResult" = proto
}
provider = "akka.remote.RemoteActorRefProvider"
}
remote {
log-received-messages = on
log-sent-messages = on
log-remote-lifecycle-events = on
enabled-transports = ["akka.remote.netty.tcp"]
netty.tcp {
hostname = "IGLR000PBG3K8Y-ubuntu"
port = 2556
log-received-messages = on
log-sent-messages = on
log-remote-lifecycle-events = on
}
}
}
}
这是我在远程计算器控制台上看到的内容
[INFO] [11/27/2013 18:40:00.425] [CalculatorApplication-akka.actor.default-dispatcher-6] [akka://CalculatorApplication/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%4010.147.137.227%3A60905-1] Message [akka.remote.transport.ActorTransportAdapter$DisassociateUnderlying] from Actor[akka://CalculatorApplication/deadLetters] to Actor[akka://CalculatorApplication/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%4010.147.137.227%3A60905-1#-1343833615] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [11/27/2013 18:40:00.429] [CalculatorApplication-akka.actor.default-dispatcher-5] [akka://CalculatorApplication/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%4010.147.137.227%3A60905-1] Message [akka.remote.transport.AssociationHandle$Disassociated] from Actor[akka://CalculatorApplication/deadLetters] to Actor[akka://CalculatorApplication/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%4010.147.137.227%3A60905-1#-1343833615] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
在计算器客户端控制台上
[INFO] [11/27/2013 18:40:00.343] [clientkernel-akka.actor.default-dispatcher-2] [akka://clientkernel/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu.ampf.com%3A2555-0/endpointWriter/endpointReader-akka.tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu%3A2555-0] Message [akka.remote.transport.AssociationHandle$Disassociated] from Actor[akka://clientkernel/deadLetters] to Actor[akka://clientkernel/system/endpointManager/reliableEndpointWriter-akka.tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu.ampf.com%3A2555-0/endpointWriter/endpointReader-akka.tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu%3A2555-0#-773728878] was not delivered. [1] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [11/27/2013 18:40:00.361] [clientkernel-akka.actor.default-dispatcher-3] [akka://clientkernel/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu%3A2555-1] Message [akka.remote.transport.AssociationHandle$Disassociated] from Actor[akka://clientkernel/deadLetters] to Actor[akka://clientkernel/system/transports/akkaprotocolmanager.tcp0/akkaProtocol-tcp%3A%2F%2FCalculatorApplication%40IGLR000PBG3K8Y-ubuntu%3A2555-1#-249262169] was not delivered. [2] dead letters encountered. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
在启用序列化之前,一切正常。我无法弄清楚我缺少哪些配置选项或做错了什么。任何帮助表示赞赏。
编辑:我是否需要扩展我的 pojo 中的任何类才能使序列化正常工作?
【问题讨论】:
标签: java scala serialization akka protocol-buffers