Class AbstractDeserializer<T,​S>

  • Type Parameters:
    T - The type of object this deserializer produces.
    S - The type of schema used for deserialization.
    All Implemented Interfaces:
    com.solace.serdes.Deserializer<T>, Closeable, AutoCloseable
    Direct Known Subclasses:
    JsonSchemaDeserializer

    public abstract class AbstractDeserializer<T,​S>
    extends Object
    implements com.solace.serdes.Deserializer<T>
    Abstract base class for deserializers that convert byte arrays into objects of type T. This class implements the Deserializer interface and provides a common structure for schema-based deserialization.
    Note: A Vertx connection will be made when configuring this Deserializer. Vertx threads are non-daemon and will prevent JVM exit, so always remember to call Deserializer.close().
    • Method Detail

      • configure

        public void configure​(Map<String,​?> properties)
        Configures the deserializer with the given properties. Properties are defined in SerdeProperties
        Note: A Vertx connection will be made when configuring this Deserializer. Vertx threads are non-daemon and will prevent JVM exit, so always remember to call Deserializer.close().
        Specified by:
        configure in interface com.solace.serdes.Deserializer<T>
        Parameters:
        properties - A Map containing configuration properties.
        See Also:
        SerdeProperties
      • deserialize

        public T deserialize​(String destinationName,
                             byte[] payload)
        Deserializes the given payload into an object of type T.

        Note: Unless the concrete class Deserializer (eg, Avro or JsonSchema) supports decoding the schema ID without headers, the schema identifier will fail to be decoded and the schema will not be resolved. In that case use deserialize(String, byte[], Map) instead where the schema ID is provided in the headers.

        Specified by:
        deserialize in interface com.solace.serdes.Deserializer<T>
        Parameters:
        destinationName - The name of the destination.
        payload - The byte array containing the serialized data.
        Returns:
        The deserialized object of type T.
      • deserialize

        public T deserialize​(String destinationName,
                             byte[] payload,
                             Map<String,​Object> headers)
        Deserializes the given payload into an object of type T, using additional headers if provided.
        Specified by:
        deserialize in interface com.solace.serdes.Deserializer<T>
        Parameters:
        destinationName - The name of the destination.
        payload - The byte array containing the serialized data.
        headers - A Map of header properties that can be used during deserialization (can be null).
        Returns:
        The deserialized object of type T.
      • close

        public void close()
        Closes this Deserializer and any open Vertx connections. This method can be called multiple times without adverse effects. Once closed, attempts to deserialize will result in a SerializationException. The deserializer can be reconfigured and reused after closing.
        Note:
        • Vertx threads are non-daemon and will prevent JVM exit, so always remember to call Deserializer.close()
        • This method is idempotent and can be called multiple times safely
        • It can be called even if the deserializer hasn't been configured
        • This method is not thread-safe while Deserializer.deserialize(String, byte[], Map) is being called
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface com.solace.serdes.Deserializer<T>