I thought I'd experiment with using akka-kryo serializer to see what difference it made to performance of persisting an event (defined by a simple case class) compared to just allowing the default java serialization
it appears to serialize the class I wanted (as I can see it in the database), but on recovery of the actor I just get
"RecoveryFailure was caused by: com.esotericsoftware.kryo.KryoException: Encountered unregistered class ID: 1636190130 (akka.actor.ActorKilledException)"
here are the relevant sections of the application.conf..
akka {
extensions = ["com.romix.akka.serialization.kryo.KryoSerializationExtension$"]
actor {
serializers {
kryo = "com.romix.akka.serialization.kryo.KryoSerializer"
}
serialization-bindings {
"com.example.State$DomainEvent" = kryo
}
}
}
kryo {
# Possibles values for type are: graph or nograph
# graph supports serialization of object graphs with shared nodes
# and cyclic references, but this comes at the expense of a small overhead
# nograph does not support object grpahs with shared nodes, but is usually faster
type = "nograph"
# Possible values for idstrategy are:
# default, explicit, incremental
#
# default - slowest and produces bigger serialized representation. Contains fully-
# qualified class names (FQCNs) for each class. Note that selecting this strategy
# does not work in version 0.3.2, but is available on master and from 0.3.3 onward.
#
# explicit - fast and produces compact serialized representation. Requires that all
# classes that will be serialized are pre-registered using the "mappings" and "classes"
# sections. To guarantee that both sender and receiver use the same numeric ids for the same
# classes it is advised to provide exactly the same entries in the "mappings" section
#
# incremental - fast and produces compact serialized representation. Support optional
# pre-registering of classes using the "mappings" and "classes" sections. If class is
# not pre-registered, it will be registered dynamically by picking a next available id
# To guarantee that both sender and receiver use the same numeric ids for the same
# classes it is advised to pre-register them using at least the "classes" section
idstrategy = "explicit"
# Define a default size for serializer pool
# Try to define the size to be at least as big as the max possible number
# of threads that may be used for serialization, i.e. max number
# of threads allowed for the scheduler
serializer-pool-size = 16
# Define a default size for byte buffers used during serialization
buffer-size = 4096
# The serialization byte buffers are doubled as needed until they exceed max-buffer-size and an exception is thrown. Can be -1 for no maximum.
max-buffer-size = -1
# If set, akka uses manifests to put a class name
# of the top-level object into each message
use-manifests = false
# Enable transparent compression of serialized messages
# accepted values are: off | lz4 | deflate
compression = off
# Log implicitly registered classes. Useful, if you want to know all classes
# which are serialized. You can then use this information in the mappings and/or
# classes sections
implicit-registration-logging = false
# If enabled, Kryo logs a lot of information about serialization process.
# Useful for debugging and lowl-level tweaking
kryo-trace = true
# If proviced, Kryo uses the class specified by a fully qualified class name
# to perform a custom initialization of Kryo instances in addition to what
# is done automatically based on the config file.
#kryo-custom-serializer-init = "CustomKryoSerializerInitFQCN"
# Define mappings from a fully qualified class name to a numeric id.
# Smaller ids lead to smaller sizes of serialized representations.
#
# This section is mandatory for idstartegy=explciit
# This section is optional for idstartegy=incremental
# This section is ignored for idstartegy=default
#
# The smallest possible id should start at 20 (or even higher), because
# ids below it are used by Kryo internally e.g. for built-in Java and
# Scala types
mappings {
"com.example.State$DomainEvent" = 20
}
# Define a set of fully qualified class names for
# classes to be used for serialization.
# The ids for those classes will be assigned automatically,
# but respecting the order of declaration in this section
#
# This section is optional for idstartegy=incremental
# This section is ignored for idstartegy=default
# This section is optional for idstartegy=explicit
classes = [
"com.example.State$DomainEvent"
]
}