Serializer that supports async serialization.
Serializer that supports async serialization.
Only used for Akka persistence journals that explicitly support async serializers.
Implementations should typically extend AsyncSerializerWithStringManifest or AsyncSerializerWithStringManifestCS that delegates synchronous calls to their async equivalents.
Scala API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.
Java API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.
Base serializer trait with serialization identifiers configuration contract,
when globally unique serialization identifier is configured in the reference.conf
.
This is a special Serializer that Serializes and deserializes byte arrays only, (just returns the byte array unchanged/uncopied)
Serializer between an object and a ByteBuffer
representing that object.
Serializer between an object and a ByteBuffer
representing that object.
Implementations should typically extend SerializerWithStringManifest and
in addition to the ByteBuffer
based toBinary
and fromBinary
methods also
implement the array based toBinary
and fromBinary
methods. The array based
methods will be used when ByteBuffer
is not used, e.g. in Akka Persistence.
Note that the array based methods can for example be implemented by delegation like this:
// you need to know the maximum size in bytes of the serialized messages val pool = new akka.io.DirectByteBufferPool(defaultBufferSize = 1024 * 1024, maxPoolEntries = 10) // Implement this method for compatibility with `SerializerWithStringManifest`. override def toBinary(o: AnyRef): Array[Byte] = { val buf = pool.acquire() try { toBinary(o, buf) buf.flip() val bytes = new Array[Byte](buf.remaining) buf.get(bytes) bytes } finally { pool.release(buf) } } // Implement this method for compatibility with `SerializerWithStringManifest`. override def fromBinary(bytes: Array[Byte], manifest: String): AnyRef = fromBinary(ByteBuffer.wrap(bytes), manifest)
This Serializer is used when akka.actor.java-serialization = off
Java API for creating a Serializer: make sure to include a constructor which takes exactly one argument of type akka.actor.ExtendedActorSystem, because that is the preferred constructor which will be invoked when reflectively instantiating the JSerializer (also possible with empty constructor).
This Serializer uses standard Java Serialization
This is a special Serializer that Serializes and deserializes nulls only
Serialization module.
Serialization module. Contains methods for serialization and deserialization as well as locating a Serializer for a particular class as defined in the mapping in the configuration.
Setup for the serialization subsystem, constructor is *Internal API*, use factories in SerializationSetup()
A Serializer represents a bimap between an object and an array of bytes representing that object.
A Serializer represents a bimap between an object and an array of bytes representing that object.
Serializers are loaded using reflection during akka.actor.ActorSystem start-up, where two constructors are tried in order:
Be sure to always use the akka.actor.DynamicAccess for loading classes! This is necessary to avoid strange match errors and inequalities which arise from different class loaders loading the same class.
Constructor is internal API: Use the factories SerializerDetails#create or SerializerDetails#apply to construct
A Serializer represents a bimap between an object and an array of bytes representing that object.
A Serializer represents a bimap between an object and an array of bytes representing that object.
For serialization of data that need to evolve over time the SerializerWithStringManifest
is recommended instead
of Serializer because the manifest (type hint) is a String
instead of a Class
. That means
that the class can be moved/removed and the serializer can still deserialize old data by matching
on the String
. This is especially useful for Akka Persistence.
The manifest string can also encode a version number that can be used in fromBinary
to
deserialize in different ways to migrate old data to new domain objects.
If the data was originally serialized with Serializer and in a later version of the
system you change to SerializerWithStringManifest
the manifest string will be the full class name if
you used includeManifest=true
, otherwise it will be the empty string.
Serializers are loaded using reflection during akka.actor.ActorSystem start-up, where two constructors are tried in order:
Be sure to always use the akka.actor.DynamicAccess for loading classes! This is necessary to avoid strange match errors and inequalities which arise from different class loaders loading the same class.
SerializationExtension is an Akka Extension to interact with the Serialization that is built into Akka