我在我的application.conf中有它:
actor {
provider = "cluster"
akka.actor.allow-java-serialization = off
serializers {
proto = "akka.remote.serialization.ProtobufSerializer"
}
serialization-bindings {
"com.google.protobuf.Message" = proto
"java.io.Serializable" = none
"sharding.Messages" = proto
}
}
和消息界面:
public interface Messages extends Serializable {
public static class RecordTemperature implements Messages {
public final Integer deviceId;
public final Double temperature;
public RecordTemperature(Integer deviceId, Double temperature) {
this.deviceId = deviceId;
this.temperature = temperature;
}
@Override
public String toString() {
return "RecordTemperature(" + deviceId + ", " + temperature + ")";
}
}
}
我遇到以下异常:
java.lang.NoSuchMethodException: sharding.Messages$RecordTemperature.toByteArray()
我还应该做其他事情/添加到配置中吗?我应该创建.proto文件和其他东西吗? Akka文档完全没有帮助,我按照文档中的说明应用了更改,但某些方法不起作用。