How to use CompatibleFieldSerializer serializer?
ikr0m opened this issue · 2 comments
Now I'm using like this and it works fine:
akka {
extensions = ["com.romix.akka.serialization.kryo.KryoSerializationExtension$"]
actor {
serializers {
kryo = "com.romix.akka.serialization.kryo.KryoSerializer"
}
serialization-bindings {
"java.io.Serializable" = kryo
}
kryo{
type = "graph"
idstrategy = "default"
serializer-pool-size = 16
buffer-size = 4096
use-manifests = false
implicit-registration-logging = true
kryo-trace = false
}
}
}
I'm using akka-persistence and akka-persistence-cassandra. When I add new field to class which is used to save in cassandra, I have an issue. Cassandra can't restore the persisted data because of new field. So I want to use kryo's CompatibleFieldSerializer serializer. I've tried like this:
kryo{
type = "graph"
...
kryo-custom-serializer-init = "com.esotericsoftware.kryo.serializers.CompatibleFieldSerializer"
}
It doesn't work. It gives "java.lang.ClassNotFoundException" exception if I add new field.
I want to use this serializer only for akka-persistence if it's possible. Do you have any idea how to do it?
I don't think you can set CompatibleFieldSerializer to kryo-custom-serializer-init. kryo-custom-serializer-init takes a class which implements def customize(kryo: Kryo): Unit .
For example:
class KryoInit { def customize(kryo: Kryo): Unit = { kryo.setDefaultSerializer(classOf[CompatibleFieldSerializer[_]]) } }
However, the customize() is being call in com.romix.akka.serialization.kryo.KryoSerializer#getKryo after "mapping" and "classes" in configuration got registered. So those classes can't utilize the new default serializer.
I propose to add a new property into the configuration, call default_serializer, to call kryo.setDefaultSerializer accordingly before "mappings" and "classes".
#140 is doing so.