Class DeserializerWrapper<T>

  • Type Parameters:
    T - the type of object created by the deserializer.
    All Implemented Interfaces:
    Closeable, AutoCloseable, org.apache.kafka.common.serialization.Deserializer<T>

    public class DeserializerWrapper<T>
    extends Object
    implements org.apache.kafka.common.serialization.Deserializer<T>
    Wraps a delegate deserializer to handle config and deserialization failures.
    • Field Detail

      • DESERIALIZATION_FAILURE_REASON

        public static final String DESERIALIZATION_FAILURE_REASON
        Header name for deserialization failure message.
        See Also:
        Constant Field Values
      • DESERIALIZATION_FAILURE_CAUSE

        public static final String DESERIALIZATION_FAILURE_CAUSE
        Header name for deserialization failure cause if any.
        See Also:
        Constant Field Values
      • DESERIALIZATION_FAILURE_IS_KEY

        public static final String DESERIALIZATION_FAILURE_IS_KEY
        Header name used when the deserialization failure happened on a key. The value is "true" in this case, absent otherwise.
        See Also:
        Constant Field Values
      • DESERIALIZATION_FAILURE_TOPIC

        public static final String DESERIALIZATION_FAILURE_TOPIC
        Header name for the topic of the incoming message when a deserialization failure happen.
        See Also:
        Constant Field Values
      • DESERIALIZATION_FAILURE_DATA

        public static final String DESERIALIZATION_FAILURE_DATA
        Header name passing the data that was not able to be deserialized.
        See Also:
        Constant Field Values
      • DESERIALIZATION_FAILURE_DESERIALIZER

        public static final String DESERIALIZATION_FAILURE_DESERIALIZER
        Header name passing the class name of the underlying deserializer.
        See Also:
        Constant Field Values
    • Method Detail

      • configure

        public void configure​(Map<String,​?> configs,
                              boolean isKey)
        Delegates to the underlying deserializer instance.
        Specified by:
        configure in interface org.apache.kafka.common.serialization.Deserializer<T>
        Parameters:
        configs - the configuration
        isKey - the key
      • deserialize

        public T deserialize​(String topic,
                             byte[] data)
        Specified by:
        deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>
      • deserialize

        public T deserialize​(String topic,
                             org.apache.kafka.common.header.Headers headers,
                             byte[] data)
        Specified by:
        deserialize in interface org.apache.kafka.common.serialization.Deserializer<T>
      • close

        public void close()
        Specified by:
        close in interface AutoCloseable
        Specified by:
        close in interface Closeable
        Specified by:
        close in interface org.apache.kafka.common.serialization.Deserializer<T>