Class ProtobufSerializer

  • All Implemented Interfaces:
    BaseSerializer, Serializer

    public class ProtobufSerializer
    extends java.lang.Object
    implements BaseSerializer
    Using the serialization-bindings as source for the whitelist. Note that the intended usage of serialization-bindings is for lookup of serializer when serializing (toBinary). For deserialization (fromBinary) the serializer-id is used for selecting serializer. Here we use serialization-bindings also when deserializing (fromBinary) to check that the manifest class is of a known (registered) type.

    If an old class is removed from serialization-bindings when it's not used for serialization but still used for deserialization (e.g. rolling update with serialization changes) it can be allowed by specifying in akka.protobuf.whitelist-class.

    That is also possible when changing a binding from a ProtobufSerializer to another serializer (e.g. Jackson) and still bind with the same class (interface).

    • Method Detail

      • serializeActorRef

        public static WireFormats.ActorRefData serializeActorRef​(ActorRef ref)
        Helper to serialize an ActorRef to Akka's protobuf representation.
        Parameters:
        ref - (undocumented)
        Returns:
        (undocumented)
      • includeManifest

        public boolean includeManifest()
        Description copied from interface: Serializer
        Returns whether this serializer needs a manifest in the fromBinary method
        Specified by:
        includeManifest in interface Serializer
        Returns:
        (undocumented)
      • fromBinary

        public java.lang.Object fromBinary​(byte[] bytes,
                                           scala.Option<java.lang.Class<?>> manifest)
        Description copied from interface: Serializer
        Produces an object from an array of bytes, with an optional type-hint; the class should be loaded using ActorSystem.dynamicAccess.
        Specified by:
        fromBinary in interface Serializer
        Parameters:
        bytes - (undocumented)
        manifest - (undocumented)
        Returns:
        (undocumented)
      • toBinary

        public byte[] toBinary​(java.lang.Object obj)
        Description copied from interface: Serializer
        Serializes the given object into an Array of Byte
        Specified by:
        toBinary in interface Serializer
        Parameters:
        obj - (undocumented)
        Returns:
        (undocumented)