Packages

p

org.apache.pekko

serialization

package serialization

Content Hierarchy
Ordering
  1. Alphabetic
Visibility
  1. Public
  2. Protected

Package Members

  1. package jackson

Type Members

  1. trait AsyncSerializer extends AnyRef

    Serializer that supports async serialization.

    Serializer that supports async serialization.

    Only used for Pekko persistence journals that explicitly support async serializers.

    Implementations should typically extend AsyncSerializerWithStringManifest or AsyncSerializerWithStringManifestCS that delegates synchronous calls to their async equivalents.

  2. abstract class AsyncSerializerWithStringManifest extends SerializerWithStringManifest with AsyncSerializer

    Scala API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.

  3. abstract class AsyncSerializerWithStringManifestCS extends AsyncSerializerWithStringManifest

    Java API: Async serializer with string manifest that delegates synchronous calls to the asynchronous calls and blocks.

  4. trait BaseSerializer extends Serializer

    Base serializer trait with serialization identifiers configuration contract, when globally unique serialization identifier is configured in the reference.conf.

  5. class ByteArraySerializer extends BaseSerializer with ByteBufferSerializer

    This is a special Serializer that Serializes and deserializes byte arrays only, (just returns the byte array unchanged/uncopied)

  6. trait ByteBufferSerializer extends AnyRef

    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 Pekko 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 org.apache.pekko.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)
  7. final case class DisabledJavaSerializer(system: ExtendedActorSystem) extends Serializer with ByteBufferSerializer with Product with Serializable

    This Serializer is used when org.apache.pekko.actor.java-serialization = off

  8. abstract class JSerializer extends Serializer

    Java API for creating a Serializer: make sure to include a constructor which takes exactly one argument of type pekko.actor.ExtendedActorSystem, because that is the preferred constructor which will be invoked when reflectively instantiating the JSerializer (also possible with empty constructor).

  9. class JavaSerializer extends BaseSerializer

    This Serializer uses standard Java Serialization

  10. class NullSerializer extends Serializer

    This is a special Serializer that Serializes and deserializes nulls only

  11. class Serialization extends Extension

    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.

  12. final class SerializationSetup extends Setup

    Setup for the serialization subsystem, constructor is *Internal API*, use factories in SerializationSetup

  13. trait Serializer extends AnyRef

    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 pekko.actor.ActorSystem start-up, where two constructors are tried in order:

    • taking exactly one argument of type pekko.actor.ExtendedActorSystem; this should be the preferred one because all reflective loading of classes during deserialization should use ExtendedActorSystem.dynamicAccess (see pekko.actor.DynamicAccess), and
    • without arguments, which is only an option if the serializer does not load classes using reflection.

    Be sure to always use the pekko.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.

  14. final class SerializerDetails extends AnyRef

    Constructor is internal API: Use the factories SerializerDetails#create or SerializerDetails#apply to construct

  15. abstract class SerializerWithStringManifest extends Serializer

    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 Pekko 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 pekko.actor.ActorSystem start-up, where two constructors are tried in order:

    Be sure to always use the pekko.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.

Value Members

  1. object BaseSerializer
  2. object DisabledJavaSerializer extends Serializable
  3. object JavaSerializer
  4. object NullSerializer extends NullSerializer
  5. object Serialization
    Annotations
    @ccompatUsedUntil213()
  6. object SerializationExtension extends ExtensionId[Serialization] with ExtensionIdProvider

    SerializationExtension is a Pekko Extension to interact with the Serialization that is built into Akka

  7. object SerializationSetup
  8. object SerializerDetails
  9. object Serializers

Ungrouped